www.webdeveloper.com
Results 1 to 3 of 3

Thread: Calling external Javascript in HTML

  1. #1
    Join Date
    Jul 2010
    Posts
    5

    Calling external Javascript in HTML

    Hi Team,

    I have created an external Javasript and calling it in HTML page. But it is not working properly.

    If i paste same code in HTML HEAD section, it works fine.

    Code is as below.

    button.js
    =======
    Code:
    browserName = navigator.appName;
    					browserVer = parseInt(navigator.appVersion);
    					if (browserName == "Netscape" && browserVer >= 3) browserVer = "1";
    					else if (browserName == "Microsoft Internet Explorer" && browserVer == 4) browserVer = "1";
    					else browserVer = "2";
    
    
    					if (browserVer == 1) 
    					{
    						home1 = new Image(112.5,27);
    						home1.src = "../images/home_0.jpg";
    						home2 = new Image(112.5,27);
    						home2.src = "../images/home_1.jpg";
    						
    						aboutsamaj1 = new Image(112.5,27);
    						aboutsamaj1.src = "../images/aboutsamaj_0.jpg";
    						aboutsamaj2 = new Image(112.5,27);
    						aboutsamaj2.src = "../images/aboutsamaj_1.jpg";
    }
    
    				
    					function hiLite(imgDocID, imgObjName, comment) 
    					{
    						if (browserVer == 1) 
    						{
    							document.images[imgDocID].src = eval(imgObjName + ".src");
    							window.status = comment; 
    							return true;
    						}
    					}
    home.html
    ========
    Code:
    <HTML>
    <HEAD>
    <TITLE> My Page</TITLE>
    <script src="js/button.js" language="javascript" ></script> 
    </HEAD>
    
    <BODY>
    <table width="200" height="700" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="">
    <a href="home.html" onMouseOver="hiLite('home','home2','Your Comment Here')" onMouseOut="hiLite('home','home1','')"><img name="home" src="images/home_0.jpg" border="0" width="112.5" height="27"hspace="0" vspace="0" align="left" /></a>
    <a href="aboutsamaj.html" onMouseOver="hiLite('aboutsamaj','aboutsamaj2'','Your Comment Here')" onMouseOut="hiLite('aboutsamaj','aboutsamaj1','')"><img name="aboutsamaj" src="images/aboutsamaj_0.jpg" border="0" width="112.5" height="27" hspace="0" vspace="0" align="left"/></a> 
    </td>
    </tr>
    </table>
    </BODY>
    </HTML>
    Could someone help me to overcome from this issue?

    Thanks,
    ACE

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    That code is out-dated to say the very least. If you tell us what you would like to do, we could probably recommend better scripts.
    Great wit and madness are near allied, and fine a line their bounds divide.

  3. #3
    Join Date
    Jul 2010
    Posts
    5
    Hi Declan,

    It is for changing the color of button with onMouseOver and OnMouseout.

    Do let me know if you know beter script.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles