SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Location
    US
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Hover script not working on home page

    Hi,

    I am using hover script below for hover images of main links. Script is working except on the home page. You can check it by going to the site in my signature. I have no idea why its functioning like this.

    SP, Script Experts, please help me

    Code:
    <!-- Hover Script -->
    <SCRIPT language="JavaScript">
    <!--
      if (document.images)
       {
    	 pic1on= new Image(55,48);
    	 pic1on.src="/images/home_on.gif";  
    	 pic2on= new Image(55,48);
    	 pic2on.src="/images/galleries_on.gif"; 
    	 pic3on= new Image(55,48);
    	 pic3on.src="/images/forum_on.gif"; 
    	 pic1off= new Image(55,48);
    	 pic1off.src="/images/home_off.gif";
    	 pic2off= new Image(55,48);
    	 pic2off.src="/images/galleries_off.gif"; 
    	 pic3off= new Image(55,48);
    	 pic3off.src="/images/forum_off.gif"; 
       }
    
    function lightup(imgName)
     {
       if (document.images)
    	{
    	  imgOn=eval(imgName + "on.src");
    	  document[imgName].src= imgOn;
    	}
     }
    
    function turnoff(imgName)
     {
       if (document.images)
    	{
    	  imgOff=eval(imgName + "off.src");
    	  document[imgName].src= imgOff;
    	}
     }
    
    //-->
    </SCRIPT>
    <!-- /Hover Script -->

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2004
    Location
    Portsmouth UK
    Posts
    1,498
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rather than say what is wrong with your script I am posting an alternative




    PHP Code:

    <a href="/index.php" >
    <
    img src="http://www.vicsjavascripts.org.uk/StdImages/Zero.gif" name="pic1" width="255" height="48" border="0"
     
    onMouseover="lightup(this,pic1on.src)"></a>

    <
    a href="/gallery/">
    <
    img src="http://www.vicsjavascripts.org.uk/StdImages/One.gif" name="pic2" width="55" height="48" border="0"
     
    onMouseover="lightup(this,pic2on.src)"></a>

    <
    a href="/forums/">
    <
    img src="http://www.vicsjavascripts.org.uk/StdImages/Two.gif" name="pic3" width="55" height="48" border="0"
     
    onMouseover="lightup(this,pic3on.src)"></a>
    &
    nbsp;&nbsp;
    </
    div></td>

    </
    tr>
    </
    table></div>
    onMouseover="lightup('pic1')" onMouseout="turnoff('pic1')"
    <SCRIPT language="JavaScript">
    <!--
      if (
    document.images)
       {
         
    pic1on= new Image(55,48);
         
    pic1on.src="http://www.vicsjavascripts.org.uk/StdImages/Three.gif";
         
    pic2on= new Image(55,48);
         
    pic2on.src="http://www.vicsjavascripts.org.uk/StdImages/Four.gif";
         
    pic3on= new Image(55,48);
         
    pic3on.src="http://www.vicsjavascripts.org.uk/StdImages/Five.gif";
         
    pic1off= new Image(55,48);
         
    pic1off.src="http://www.vicsjavascripts.org.uk/StdImages/Zero.gif";
         
    pic2off= new Image(55,48);
         
    pic2off.src="http://www.vicsjavascripts.org.uk/StdImages/One.gif";
         
    pic3off= new Image(55,48);
         
    pic3off.src="http://www.vicsjavascripts.org.uk/StdImages/Two.gif";
       }

    function 
    lightup(obj,imgOver){
     if (
    document.images)    {
      
    obj.outimg=obj.src;
      
    obj.src=imgOver;
      
    obj.onmouseout=function(){
                      
    this.src=this.outimg;
                     }
     }
    }

    //-->
    </SCRIPT> 

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2005
    Location
    US
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vwphillips
    Rather than say what is wrong with your script I am posting an alternative
    Thanks phillips, its working like magin


Bookmarks

Posting Permissions

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