[thelist] Email address hiding question

David Bailey d.bailey at dab-hand.co.nz
Thu Jun 30 19:55:05 CDT 2005


Hi,

I am having trouble with a JS script designed to hide email addresses on a
web site. It was supplied in a newsletter and I can't get hold of the
developer of the script.

It appeals to me in that it is supposed to work if Javascript is turned off
in the user's browser.

What the script is meant to do:
======================================
The URL has been 'decorated' with some spam blocking parts, and a hint
appears in the message body ('Please remove spam blocker'). If a user has
JavaScript enabled, the onClick() event handler takes control, which
exchanges the spam-blocking part with an at-sign. Additionally, the hint is
removed because it is no longer needed.

The Problem:
============
It works correctly in a non-JS-enabled browser, but in a JS enabled web
browser the following problems occur:
1. When the link is clicked it opens two email windows!
2. The first window opens as it should with the "no-spam" text stripped from
the email address, but contains the 'Please remove spam blocker' message in
the Body.
3. The second window (which opens over the top of the correct window)
contains the 'no-spam' text in the email address (and "correctly" contains
the Subject message).
4. The process seems to open another browser window

I don't know enough about js to work out what is wrong. Can anyone help
here?

I reproduce the script below, but it can also be found as a working example
at:
http://www.dab-hand.co.nz/testbay/email/emailtest.html
(The script works the top link called "Information"

The script goes:
================

In the head of the page:

function sendmail() {
   // cancel std event processing
   event.returnValue = false;
   // remove spam blocker
   var url = event.srcElement.href.replace(".no-spam at please.", "@");
   url = url.replace("Please remove spam blocker. ", "");
   // open email window
   window.open(url);
}

In the body:

<p>
<a href="mailto:info.no-spam at please.adomain.com
?subject=Put you subject header here.
&body=Please remove spam blocker. Place your message here. Thank you!"
onClick="sendmail()">Information</a>
</p>


Thanks for any help anyone can give me!

David



More information about the thelist mailing list