Hivelogic Email Address Encoder with Image Rollover
I am using the <a href="http://www.hivelogic.com/safeaddress/index.php" target="_blank">Hivelogic Email Address Encoder</a> to help shield my email address from harvesting robots. This all works fine and dandy, but I don't want to always have a text link.
What I would like to do is to have an image that changes on rollover that youwould click on to email me.
Basically, I want to combine:
[code]<script type="text/javascript">
<!--
\tvar first = 'ma';
\tvar second = 'il';
\tvar third = 'to:';
\tvar address = 'tyler';
\tvar domain = 'stroszek.com';
\tdocument.write('<a href="');
\tdocument.write(first+second+third);
\tdocument.write(address);
\tdocument.write('@');
\tdocument.write(domain);
\tdocument.write('" class="menuItem" title="email me">');
\tdocument.write('email me<\\/a>');
// -->
</script>
</pre><hr></blockquote>
and
[CODE]<script language="JavaScript" type="text/JavaScript">
<!--
[ 11-18-2002: Message edited by: Stroszek ]</p>
What I would like to do is to have an image that changes on rollover that youwould click on to email me.
Basically, I want to combine:
[code]<script type="text/javascript">
<!--
\tvar first = 'ma';
\tvar second = 'il';
\tvar third = 'to:';
\tvar address = 'tyler';
\tvar domain = 'stroszek.com';
\tdocument.write('<a href="');
\tdocument.write(first+second+third);
\tdocument.write(address);
\tdocument.write('@');
\tdocument.write(domain);
\tdocument.write('" class="menuItem" title="email me">');
\tdocument.write('email me<\\/a>');
// -->
</script>
</pre><hr></blockquote>
and
[CODE]<script language="JavaScript" type="text/JavaScript">
<!--
[ 11-18-2002: Message edited by: Stroszek ]</p>
Comments
I've tried various combinations, but can't seem to get anything that works quite right. Does anyone out there have any ideas? Any help would be greatly appreciated.
[ 11-18-2002: Message edited by: Stroszek ]</p>
try it in stages: can you get a linked image to work without a rollover? You should be able to simply by replacing the text inside the <a> tags ("email me" in your example) with an <img> tag.
Once you get that the rest should be a simple matter of making sure you escape all the special characters. The slash / and single quote ' are the ones to watch for.
Is this what you mean by escaping them?
<script type="text/javascript">
<!--
\tvar first = 'ma';
\tvar second = 'il';
\tvar third = 'to:';
\tvar address = 'tyler';
\tvar domain = 'stroszek.com';
\tdocument.write('<a href="');
\tdocument.write(first+second+third);
\tdocument.write(address);
\tdocument.write('@');
\tdocument.write(domain);
\tdocument.write('<img src=\\"..\\/images\\/contact.gif\\" alt=\\"Contact\\" name=\\"iconCont\\" width=\\"49\\" height=\\"100\\" hspace=\\"0\\" vspace=\\"0\\" border=\\"0\\" id=\\"iconCont\\" onmouse over=\\"MM_swapImage(\\'iconCont\\',\\'',\\'..\\/images\\/contactA.gif\\',\\'blueCont\\',\\'',\\'..\\/images\\/contactBlueA.gif\\',1)\\" onmouse out=\\"MM_swapImgRestore()\\" \\/><\\/a>');
(UBB won't permit the onmouse over to be one word, so i had to break it up, it's one word on my page)
I have a feeling that the \\" should just be ", but neither one will work for me...
[ 11-18-2002: Message edited by: Stroszek ]</p>
Using the standard Hivelogic javascript, I get a blank page that has an email link on it. I have played around with using window.open, but I don't really like a blank window opening before the email window launches.
Anyone have an idea about how to alter the hivelogic javascript like I want?
[ 11-18-2002: Message edited by: Stroszek ]</p>
<strong>I have kind of gotten it to work by doing the image rollover normally, and then adding <a href="javascript:;" on click="mail()"></a> around the rollover. (UBB won't let me post on click as one word, but it is in my document). Now the only problem that I have is getting the javascript to open an email window.
Using the standard Hivelogic javascript, I get a blank page that has an email link on it. I have played around with using window.open, but I don't really like a blank window opening before the email window launches.
Anyone have an idea about how to alter the hivelogic javascript like I want?
</strong><hr></blockquote>
You were on the right track the first time. You just got stuck by a few minor errors and you had no feedback to see what was wrong. Try this version and it will open a panel with the generated text to aid in debugging. Just comment out the line when you are finished with it.
not 100% tested but should be fine.
<script type="text/javascript">
<!--
\tvar first = 'ma';
\tvar second = 'il';
\tvar third = 'to:';
\tvar address = 'tyler';
\tvar domain = 'stroszek.com';
\tvar doc = '<a href="';
\tdoc = doc + first+second+third;
\tdoc = doc + address;
\tdoc = doc + '@';
\tdoc = doc + domain;
\tdoc = doc + '" class="menuItem" title="email me">';
\tdoc = doc + '<img src="../images/contact.gif" alt="Contact" name="iconCont" width="49" height="100" hspace="0" vspace="0" border="0" id="iconCont" onmouseout="MM_swapImage(\\'iconCont\\',\\'\\',\\' ../images/contactA.gif\\',\\'blueCont\\',\\'\\',\\'../images/contactBlueA.gif\\',1)" onmouseout="MM_swapImgRestore() >';
\tdoc = doc + '</a>';
\talert(doc);
\tdocument.write( doc );
// -->
</script>
You missed a few escapes the last time. Don't escape the double quotes and look out for two single quotes with nothing between them that look like double quotes. The slashes don't appear to need escaped.
good luck