Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-18-2005, 02:49 PM   PM User | #1
mr johnson
New Coder

 
Join Date: Jan 2004
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
mr johnson is an unknown quantity at this point
call js from graphic

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>
mr johnson is offline   Reply With Quote
Old 04-18-2005, 03:51 PM   PM User | #2
glenmac
Regular Coder

 
Join Date: Nov 2003
Location: Vancouver Island Canada
Posts: 139
Thanks: 0
Thanked 0 Times in 0 Posts
glenmac is an unknown quantity at this point
Change your js file to reference the image you want to use.
Code:
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.
__________________
lantzvillecomputers.com

Last edited by glenmac; 04-18-2005 at 04:03 PM..
glenmac is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:35 PM.


Advertisement
Log in to turn off these ads.