1 Replies - 957 Views - Last Post: 07 September 2010 - 10:36 PM

#1 S3lkies  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 248
  • Joined: 09-January 09

Javascript file

Posted 07 September 2010 - 08:15 PM

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="CSS/Pages.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<body class="Background" onload="MM_preloadImages('Navigation Bar/images/Over_01.gif','Navigation Bar/images/Over_02.gif','Navigation Bar/images/Over_03.gif','Navigation Bar/images/Over_04.gif','Navigation Bar/images/Over_05.gif','Navigation Bar/images/Over_06.gif','Navigation Bar/images/Over_08.gif')">
<a href="Index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','Navigation Bar/images/Over_01.gif',1)"><img src="Navigation Bar/images/Normal_01.gif" alt="Home" name="Home" width="81" height="125" border="0" id="Home" /></a><a href="About Us.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('About Us','','Navigation Bar/images/Over_02.gif',1)"><img src="Navigation Bar/images/Normal_02.gif" alt="About Us" name="About Us" width="83" height="125" border="0" id="About Us" /></a><a href="Pumps.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Pumps','','Navigation Bar/images/Over_03.gif',1)"><img src="Navigation Bar/images/Normal_03.gif" alt="Pumps" name="Pumps" width="97" height="125" border="0" id="Pumps" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','Navigation Bar/images/Over_04.gif',1)"><img src="Navigation Bar/images/Normal_04.gif" alt="" name="Image5" width="2" height="125" border="0" id="Image5" /></a><a href="Contact information.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact Details','','Navigation Bar/images/Over_05.gif',1)"><img src="Navigation Bar/images/Normal_05.gif" alt="Contact Details" name="Contact Details" width="95" height="125" border="0" id="Contact Details" /></a><a href="Contactform.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact Us','','Navigation Bar/images/Over_06.gif',1)"><img src="Navigation Bar/images/Normal_06.gif" alt="Contact Us" name="Contact Us" width="89" height="125" border="0" id="Contact Us" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','Navigation Bar/images/Over_07.gif',0)"><img src="Navigation Bar/images/Normal_07.gif" alt="" name="Image8" width="1" height="125" border="0" id="Image8" /></a><a href="Find us.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Find Us','','Navigation Bar/images/Over_08.gif',1)"><img src="Navigation Bar/images/Normal_08.gif" alt="Find Us" name="Find Us" width="92" height="125" border="0" id="Find Us" /></a>
</body>

</html>



That is what I have in my html file as of now,

I however want to change this to make it neater.

so I changed it to this.

INDEX.HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="CSS/Pages.css" rel="stylesheet" type="text/css" />
<script type="javascript" src="Javascript/navbarjava.js"></script>

<b>everything else goes bellow </b>
</body>

</html>



Navbarjava.js
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

<body class="Background" onload="MM_preloadImages('Navigation Bar/images/Over_01.gif','Navigation Bar/images/Over_02.gif','Navigation Bar/images/Over_03.gif','Navigation Bar/images/Over_04.gif','Navigation Bar/images/Over_05.gif','Navigation Bar/images/Over_06.gif','Navigation Bar/images/Over_08.gif')">
<a href="Index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Home','','Navigation Bar/images/Over_01.gif',1)"><img src="Navigation Bar/images/Normal_01.gif" alt="Home" name="Home" width="81" height="125" border="0" id="Home" /></a><a href="About Us.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('About Us','','Navigation Bar/images/Over_02.gif',1)"><img src="Navigation Bar/images/Normal_02.gif" alt="About Us" name="About Us" width="83" height="125" border="0" id="About Us" /></a><a href="Pumps.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Pumps','','Navigation Bar/images/Over_03.gif',1)"><img src="Navigation Bar/images/Normal_03.gif" alt="Pumps" name="Pumps" width="97" height="125" border="0" id="Pumps" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image5','','Navigation Bar/images/Over_04.gif',1)"><img src="Navigation Bar/images/Normal_04.gif" alt="" name="Image5" width="2" height="125" border="0" id="Image5" /></a><a href="Contact information.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact Details','','Navigation Bar/images/Over_05.gif',1)"><img src="Navigation Bar/images/Normal_05.gif" alt="Contact Details" name="Contact Details" width="95" height="125" border="0" id="Contact Details" /></a><a href="Contactform.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Contact Us','','Navigation Bar/images/Over_06.gif',1)"><img src="Navigation Bar/images/Normal_06.gif" alt="Contact Us" name="Contact Us" width="89" height="125" border="0" id="Contact Us" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','Navigation Bar/images/Over_07.gif',0)"><img src="Navigation Bar/images/Normal_07.gif" alt="" name="Image8" width="1" height="125" border="0" id="Image8" /></a><a href="Find us.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Find Us','','Navigation Bar/images/Over_08.gif',1)"><img src="Navigation Bar/images/Normal_08.gif" alt="Find Us" name="Find Us" width="92" height="125" border="0" id="Find Us" /></a> 


I get an error "There is a syntax error on line 25." It doesnt tell me what it is, and I have no idea, what it is ALSO when I preview my file the navigation bar is gone.... I dont know whats happening, I tried changing the location of the images (right down to "C:/extensiontofileinhere") but still nothing

I then tried leaving the
<body class="Background" onload="MM_preloadImages('Navigation Bar/images/Over_01.gif','Navigation Bar/images/Over_02.gif','Navigation Bar/images/Over_03.gif','Navigation Bar/images/Over_04.gif','Navigation Bar/images/Over_05.gif','Navigation Bar/images/Over_06.gif','Navigation Bar/images/Over_08.gif')">
incase that is what needs to be there in the .html file for the images to stay there - but once again to no prevail.

Sorry about posting a few different things asking for help ><.

S3lkies

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript file

#2 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3572
  • View blog
  • Posts: 10,414
  • Joined: 08-June 10

Re: Javascript file

Posted 07 September 2010 - 10:36 PM

you canít have HTML markup in a Javascript file. put the HTML block back in the HTML file (where it belongs). the <script> tags donít work like an include in PHP
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1