Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jan 2004
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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>

  • #2
    Regular Coder
    Join Date
    Nov 2003
    Location
    Vancouver Island Canada
    Posts
    139
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by glenmac; 04-18-2005 at 04:03 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •