...

View Full Version : call js from graphic



mr johnson
04-18-2005, 03:49 PM
Hi All,

I found this code to hide an email address, did a few tweaks and it works fine. I'd like to call the routine by clicking a graphic rather than plain text but the examples I've seen are perhaps more complex than I need here (uh, didn't understand) or related to other tasks.

Can someone offer suggestions or point me to a tutorial that would point out this basic syntax? It seems that the function must be modified to something that includes an onclick and/or a path to the image. The head and body could remain as is?

Thanks

mr johnson

This resides in the directory format

var somebody = "mrdeeds";
var somewhere = "washington.com";

function hem()
{
document.write("<a href=\"mailto");
document.write(":" + somebody + "@");
document.write(somewhere + "\">" + somebody + "@" + somewhere + "<\/a>");
}

this is in the head

<script language="JavaScript" src="format/hem.js">
</script>

this is in the body

<script language="JavaScript" type="text/javascript">
hem()
</script>

glenmac
04-18-2005, 04:51 PM
Change your js file to reference the image you want to use.


var somebody = "mrdeeds";
var somewhere = "washington.com";

function hem()
{
document.write("<a href=\"mailto");
document.write(":" + somebody + "@");
document.write(somewhere + "\">" + "<img src = YourImage.jpg><\/a>");
}

If you used an onclick handler, because you're using document.write your page would be overwritten.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum