rabbits2
asked on
Reset Scrollbar of Layer Onclick
I have a htm page layed out in dreamweaver, using one layer to house the menu system ,madeup of gif images with behaviors attached, and another layer which holds an image. This layer holding the image is set to auto scroll. What i want to happen is to click through the menu and onCLick of each button the iamge to change in layer two. This is working fine, the problem I have is that iwth some images you need to scroll down to view it all, but if I scroll down and then click a diff button to view a new image the scrollbar of this layer which houses the images remains scrolled down when I wish it to reset on click to the top.
Below is my code for you to see:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(p arseInt(ap pVersion)= =4)) {
document.MM_pgW=innerWidth ; document.MM_pgH=innerHeigh t; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_p gW || innerHeight!=document.MM_p gH) location.reload();
}
MM_reloadPage(true);
// -->
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x= a[i])&&x.o Src;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_pre loadImages .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.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p arent.fram es.length) {
d=parent.frames[n.substrin g(p+1)].do cument; 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.len gth;i++) x=MM_findObj(n,d.layers[i] .document) ;
if(!x && document.getElementById) x=document.getElementById( n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arg uments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+= 3)
if ((x=MM_findObj(a[i]))!=nul l){documen t.MM_sr[j+ +]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_preloadImages(' images/men u_ourcompb ig.gif','i mages/menu _meet9_f2. gif','imag es/txt_lon don.gif',' images/txt _consumer. gif')">
<div id="Layer1" style="position:absolute; left:119px; top:50px; width:203px; height:330px; z-index:1"><a href="#" onClick="MM_swapImage('Ima ge1','','i mages/menu _ourcompbi g.gif','tx t','','ima ges/txt_co nsumer.gif ',1)"><img name="Image1" border="0" src="images/menu_ourcomp1. gif" width="317" height="36"></a><a href="#" onClick="MM_swapImage('Ima ge3','','i mages/menu _meet9_f2. gif','txt' ,'','image s/txt_lond on.gif',1) "><img name="Image3" border="0" src="images/menu_meet9.gif " width="317" height="28"></a></div>
<div id="Layer2" style="position:absolute; left:454px; top:49px; width:508px; height:200px; z-index:2; overflow: auto"><img src="images/txt_consumer.g if" width="429" height="474" name="txt"></div>
</body>
</html>
Many thanks for your help..
Below is my code for you to see:
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript">
<!--
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(p
document.MM_pgW=innerWidth
else if (innerWidth!=document.MM_p
}
MM_reloadPage(true);
// -->
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=
}
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_pre
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&p
d=parent.frames[n.substrin
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;
for(i=0;!x&&d.layers&&i<d.
if(!x && document.getElementById) x=document.getElementById(
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arg
if ((x=MM_findObj(a[i]))!=nul
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" onLoad="MM_preloadImages('
<div id="Layer1" style="position:absolute; left:119px; top:50px; width:203px; height:330px; z-index:1"><a href="#" onClick="MM_swapImage('Ima
<div id="Layer2" style="position:absolute; left:454px; top:49px; width:508px; height:200px; z-index:2; overflow: auto"><img src="images/txt_consumer.g
</body>
</html>
Many thanks for your help..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
[code]
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arg
if ((x=MM_findObj(a[i]))!=nul
window.setTimeout("documen
}
[/code]
You may not need this stuff wrapped in a setTimeout, but it's probably safer this way.
Hope this is what you're looking for,
-Frag