Gnomo
Registered
I have a puzzle of a javascript that I could use help with.
I am trying to come up with a method for putting email addresses into a website in such a way that they cannot be harvested by spambots (The javascript methods of "encoding" the email address are not secure enough IMHO), however my bosses are mandating that if someone click on the email link that it open their email client, so I can't use a email form. I also want to incorporate the companies LDAP server into the scenario so that if someone changes their email address, I don't have to recode pages.
So, here is what I would like to do:
The user click on a link on the web page. A pop-under window appears that calls a PHP page that queries the LDAP server and returns a http-location header that opens the email client. The pop-under window should then automatically disappear.
So far I have the PHP script working and it returns the header I need and the email client does open. Also I can create a pop-under window that will automatically disappear (since a http-location header is being returned, I can't put any javascript after it to close the window).
The problem that I am having is that whenever I try to combine the two (have the pop-under window link to the php page) either the window does not close, or the php page does not "load" until the javascript has completed executing (in which case the window is closed before the needed header is returned). I have tried various methods to delay the execution of the window.close command, however it always seems that this either causes the command to not execute (as is the case with setTimeout() ) or the page does load until after the javascript completes (as is the case with do nothing loops)
Here is what my javascript looks like:
<a href="" onClick="popUnder = window.open('test.php?name=foo');popUnder.blur();popUnder.close();">Email me</a>
Any Help or Ideas of other ways to open a email client from a web browser would be appreciated.
I am trying to come up with a method for putting email addresses into a website in such a way that they cannot be harvested by spambots (The javascript methods of "encoding" the email address are not secure enough IMHO), however my bosses are mandating that if someone click on the email link that it open their email client, so I can't use a email form. I also want to incorporate the companies LDAP server into the scenario so that if someone changes their email address, I don't have to recode pages.
So, here is what I would like to do:
The user click on a link on the web page. A pop-under window appears that calls a PHP page that queries the LDAP server and returns a http-location header that opens the email client. The pop-under window should then automatically disappear.
So far I have the PHP script working and it returns the header I need and the email client does open. Also I can create a pop-under window that will automatically disappear (since a http-location header is being returned, I can't put any javascript after it to close the window).
The problem that I am having is that whenever I try to combine the two (have the pop-under window link to the php page) either the window does not close, or the php page does not "load" until the javascript has completed executing (in which case the window is closed before the needed header is returned). I have tried various methods to delay the execution of the window.close command, however it always seems that this either causes the command to not execute (as is the case with setTimeout() ) or the page does load until after the javascript completes (as is the case with do nothing loops)
Here is what my javascript looks like:
<a href="" onClick="popUnder = window.open('test.php?name=foo');popUnder.blur();popUnder.close();">Email me</a>
Any Help or Ideas of other ways to open a email client from a web browser would be appreciated.