有2个页面.a.html嵌入在index.html中...
有2个页面.a.html嵌入在index.html中如下:
index.html:
<html>
<head>
</head>
<body scroll= "auto ">
<br> <br> <br> <br> <br> <br>
<iframe id= "Myiframe " src= "a.html " scrolling= "no " style= "border:0px;width:100%;height:100% " frameborder= "0 "> </iframe>
<br> <br> <br> <br> <br> <br> <br> <br> <br>
<br> <br> <br> <br> <br> <br> <br> <br> <br>
</body>
</html>
a.html:
<html>
<head>
</head>
<body>
以下子页内容 <br> <br> <br> <br> <br> <br> <br>
<a href= "# "> 点击我能否控制主页滚动条滚动到顶部 </a>
<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />
以上子页内容
</body>
</html>
现在浏览index.html,点击a里面的超连接.滚动条会跑到中间,我想让滚动跳跑到最顶部.怎么实现呢?麻烦测试一下.
------解决方案-------------------- <html>
<head>
</head>
<body scroll= "auto ">
<a name= "#p1 "> </a>
<br> <br> <br> <br> <br> <br>
<iframe id= "Myiframe " src= "a.html " scrolling= "no " style= "border:0px;width:100%;height:100% " frameborder= "1 "> </iframe>
<br> <br> <br> <br> <br> <br> <br> <br> <br>
<br> <br> <br> <br> <br> <br> <br> <br> <br>
</body>
</html>
a.html:
<html>
<head>
</head>
<body>
以下子页内容 <br> <br> <br> <br> <br> <br> <br>
<a href= "#p1 "> 点击我能否控制主页滚动条滚动到顶部 </a>
<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />
以上子页内容
</body>
</html>
------解决方案--------------------function test()
{
parent.scrollTo(0, 0);
}
</script>
以下子页内容
<br> <br> <br> <br> <br> <br> <br>
<a href= "javascript:test(); "> 点击我能否控制主页滚动条滚动到顶部 </a>
<br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br />
以上子页内容