Hivelogic Email Address Encoder with Image Rollover

Posted:
in Genius Bar edited January 2014
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]&lt;script type="text/javascript"&gt;

&lt;!--

\tvar first = 'ma';

\tvar second = 'il';

\tvar third = 'to:';

\tvar address = 'tyler';

\tvar domain = 'stroszek.com';

\tdocument.write('&lt;a href="');

\tdocument.write(first+second+third);

\tdocument.write(address);

\tdocument.write('@');

\tdocument.write(domain);

\tdocument.write('" class="menuItem" title="email me"&gt;');

\tdocument.write('email me&lt;\\/a&gt;');

// --&gt;

&lt;/script&gt;

</pre><hr></blockquote>



and



[CODE]&lt;script language="JavaScript" type="text/JavaScript"&gt;

&lt;!--



[ 11-18-2002: Message edited by: Stroszek ]</p>

Comments

  • Reply 1 of 6
    Well I can't get the entire post to post, I don't know what's up, but you get the picture, I want to combine what's up there with a standard javascript rollover effect...



    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>
  • Reply 2 of 6
    hmmm. It's difficult to tell where you are going wrong.



    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 &lt;a&gt; tags ("email me" in your example) with an &lt;img&gt; 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.
  • Reply 3 of 6
    I can get the image to work, but the rollover won't. I suspected that it had something to do with the ' and the / characters, but i'm not sure what you mean by escape them... I tried replacing them with their ascii equivlient, but that doesn't work....



    Is this what you mean by escaping them?

    &lt;script type="text/javascript"&gt;

    &lt;!--

    \tvar first = 'ma';

    \tvar second = 'il';

    \tvar third = 'to:';

    \tvar address = 'tyler';

    \tvar domain = 'stroszek.com';

    \tdocument.write('&lt;a href="');

    \tdocument.write(first+second+third);

    \tdocument.write(address);

    \tdocument.write('@');

    \tdocument.write(domain);

    \tdocument.write('&lt;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()\\" \\/&gt;&lt;\\/a&gt;');





    (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>
  • Reply 4 of 6
    I have kind of gotten it to work by doing the image rollover normally, and then adding &lt;a href="javascript:;" on click="mail()"&gt;&lt;/a&gt; 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?



    [ 11-18-2002: Message edited by: Stroszek ]</p>
  • Reply 5 of 6
    [quote]Originally posted by Stroszek:

    <strong>I have kind of gotten it to work by doing the image rollover normally, and then adding &lt;a href="javascript:;" on click="mail()"&gt;&lt;/a&gt; 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.



    &lt;script type="text/javascript"&gt;

    &lt;!--

    \tvar first = 'ma';

    \tvar second = 'il';

    \tvar third = 'to:';

    \tvar address = 'tyler';

    \tvar domain = 'stroszek.com';

    \tvar doc = '&lt;a href="';

    \tdoc = doc + first+second+third;

    \tdoc = doc + address;

    \tdoc = doc + '@';

    \tdoc = doc + domain;

    \tdoc = doc + '" class="menuItem" title="email me"&gt;';

    \tdoc = doc + '&lt;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() &gt;';

    \tdoc = doc + '&lt;/a&gt;';

    \talert(doc);

    \tdocument.write( doc );

    // --&gt;

    &lt;/script&gt;



    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
  • Reply 6 of 6
    Thank you. You are my new bestfriend. Well, not really, but you're pretty high on the list.
Sign In or Register to comment.