Forum Moderators: open
The problem is, ive used Macromedia Dreameaver Rollover buttons, which are in the header.asp, i would like to put the <script> into an external .js file, but each time i seperate the code i get an error,
here is the code :-
<script>
<!--
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>
<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="images/MainTopPanel.jpg" width="760" height="94" /></td>
</tr>
<tr>
<td><a href="index1.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','images/nav%20buttons/Home%20Y.jpg',1)"><img src="images/nav%20buttons/Home%20W.jpg" alt="home" name="Image2" width="259" height="24" border="0" id="Image2" /></a><a href="biography.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','images/nav%20buttons/Biog%20Y.jpg',1)"><img src="images/nav%20buttons/Biog%20W.jpg" alt="biography" name="Image4" width="125" height="24" border="0"></a><a href="album.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','images/nav%20buttons/Album%20Y.jpg',1)"><img src="images/nav%20buttons/Album%20W.jpg" alt="albums" name="Image3" width="92" height="24" border="0"></a><a href="news.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','images/nav%20buttons/News%20Y.jpg',1)"><img src="images/nav%20buttons/News%20W.jpg" alt="news and gigs" name="Image5" width="128" height="24" border="0"></a><a href="contact.asp" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','images/nav%20buttons/Contact%20Y.jpg',1)"><img src="images/nav%20buttons/Contact%20W.jpg" alt="contacts" name="Image6" width="156" height="24" border="0"></a></td>
</tr>
</table>
My body tags etc are in the main index.asp.
Can someone please explain if it is possable to seperate the above script code and place it into a .js file, ive tried but with no luck
thanks
Since we're on the subject of Macromedia rollovers, though, I would take about 10 minutes and ditch all that bloated code. Do a search here on the site for rollover buttons and you'll find a way to do the same thing in about 6 lines of code. If you don't find one, post again, and I'll post what I use. It's clean, easy to understand, and always works if the user has javascript.
However txbakers, ive looked around for this shorter script and cannot find it :(
If you can point me in the right direction id be gratefull :)
Is this code browser compliant? if so id like to use it if its shorter, as i dont really understand what all this bloated code does anyway.
thankyou both
Andy