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 4 of 4
  1. #1
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts

    javascript as a link

    I have the following code to change an image onMouseDown. I was wondering if it was possible to have the browser go to www.google.com onMouseUp. I dont want to have to use a "<a>" because of the little border that it produces.

    Code:
    <html>
    <head>
    <script language="JavaScript">
    <!--
    // PRELOADING IMAGES
    if (document.images) {
     img_on =new Image();  img_on.src ="splashDown.gif"; 
     img_off=new Image();  img_off.src="splashUp.gif"; 
    }
    
    function handlePress() { 
     if (document.images) document.imgName.src=img_on.src;
    }
    
    function handleRelease() {
     if (document.images) document.imgName.src=img_off.src;
    }
    
    //-->
    </script>
    </head>
    <body>
    <div onMouseDown="handlePress()" onMouseUp="handleRelease()">
    <img src="splashUp.gif" border="0" name="imgName">
    </div>
    </body>
    </html>
    Last edited by Antoniohawk; 10-26-2003 at 02:48 AM.

  • #2
    Registered User
    Join Date
    Jun 2002
    Location
    Arizona
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Add onClick="window.location='http://domain.com/'" to the <img /> tag.

    <img src="splashUp.gif" border="0" name="imgName" onClick="window.location='http://domain.com/'">

  • #3
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Use the a element but add this to your stylesheets:
    Code:
    a img{
        border-style: none;
    }
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #4
    Senior Coder
    Join Date
    Aug 2002
    Location
    Kansas City, Kansas
    Posts
    1,518
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Phip ur idea works great. I tried using the <a> + the style and the border still was there when i clicked. Not sure if i did something wrong.
    Last edited by Antoniohawk; 10-26-2003 at 10:53 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
    •