用js实现鼠标滚动无法控制iframe页面的上下载滚动? 用js实现鼠标滚动无法控制iframe页面的上下载滚动?谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 楼主是不是要这个啊scolling="no" 在iframe里面的页面onScroll="document.body.scrollTop=0" 后,连鼠标左键硬性拖拽也不灵光了,呵呵。<html> <head> <title></title> </head> <body> <iframe src="test.html" height="100" width="100%" scrolling="no" onScroll="alert('a')"> </iframe> </body></html><html> <head> <title></title> </head> <body onScroll="document.body.scrollTop=0" > <p style="height: 200px;">test</p> </body></html> 修正第一个<html> <head> <title></title> </head> <body> <iframe src="test.html" height="100" width="100%" scrolling="no"> </iframe> </body></html> 谢谢各位,现在出现了一个新的需求,当鼠标移动到ifreme页面上去的时候,让滚动鼠标失效(针对父窗口) 方案1<html> <head> <title></title> </head> <body> <iframe src="test.html" height="100" width="100%" > </iframe> <p style="height: 99999px;">test</p> </body></html><html> <head> <title>子窗口</title> </head> <body onmouseover="window.parent.document.body.style.overflow='hidden';" onmouseout="window.parent.document.body.style.overflow='';"> </body></html> 调了好一会还是感觉有点抖动,不是很好,嗨不抖的话就完美了。<html> <head> <title></title> <script type="text/javascript"> function scrollListener(){ demo.innerHTML="scrollListener"+new Date(); document.body.onscroll=scrollListener; window.lastScrollIdx=document.body.scrollTop; } function keepScroll(){ document.body.onscroll=keepScroll; if(window.lastScrollIdx==null) window.lastScrollIdx=document.body.scrollTop; demo.innerHTML="keepScroll"+new Date(); document.body.scrollTop=window.lastScrollIdx; } </script> </head> <body onscroll="scrollListener()"> <iframe src="test.html" height="300" width="100%" > </iframe> <div style="height: 99999px;" id="demo">test</div> </body></html><html> <head> <title>子窗口</title> </head> <body onmouseover="window.parent.keepScroll();test.innerHTML='over'" onmouseout="window.parent.scrollListener();test.innerHTML='out'"> <div id="test"></div> </body></html> 又算了一会发现无法计算出 浏览器边框线的宽度,自己调整了6px<html> <head> <title></title> </head> <body> <iframe src="test.html" height="100" width="100%" > </iframe> <p style="height: 99999px;">test</p> </body></html><html> <head> <title>子窗口</title> <script type="text/javascript"> var tmp; function over(){ var p=window.parent; tmp=p.document.body.offsetWidth-p.document.body.clientWidth+6; p.document.body.style.marginRight=tmp; p.document.body.style.overflow='hidden'; } function out(){ var p=window.parent; p.document.body.style.marginRight=""; p.document.body.style.overflow=''; } </script> </head> <body onmouseover="over();" onmouseout="out();"> </body></html> struts2里取request的问题 如何用java做登陆界面? 求助,急,在线等!!! javascript中的问题 jsp能否将要显示的信息缓存起来一起输出? 最简单JSP页面出现乱码!!! 一个比较奇怪的问题。session cookie相关的。 用户游览时在页面上启动了一个Timer,如何在用户关闭游览器时停止此Timer? JSP问题 开发jsp用什么工具好? 请教开发中的一点小问题 为什么dwrutil.removeallopions() 无法使用
scolling="no"
<html>
<head>
<title></title>
</head>
<body>
<iframe src="test.html" height="100" width="100%" scrolling="no" onScroll="alert('a')"> </iframe>
</body>
</html>
<html>
<head>
<title></title>
</head>
<body onScroll="document.body.scrollTop=0" >
<p style="height: 200px;">test</p>
</body>
</html>
<html>
<head>
<title></title>
</head>
<body>
<iframe src="test.html" height="100" width="100%" scrolling="no"> </iframe>
</body>
</html>
<html>
<head>
<title></title>
</head>
<body>
<iframe src="test.html" height="100" width="100%" > </iframe>
<p style="height: 99999px;">test</p>
</body>
</html>
<html>
<head>
<title>子窗口</title>
</head>
<body onmouseover="window.parent.document.body.style.overflow='hidden';" onmouseout="window.parent.document.body.style.overflow='';">
</body>
</html>
<html>
<head>
<title></title>
<script type="text/javascript">
function scrollListener(){
demo.innerHTML="scrollListener"+new Date();
document.body.onscroll=scrollListener;
window.lastScrollIdx=document.body.scrollTop;
}
function keepScroll(){
document.body.onscroll=keepScroll;
if(window.lastScrollIdx==null)
window.lastScrollIdx=document.body.scrollTop;
demo.innerHTML="keepScroll"+new Date();
document.body.scrollTop=window.lastScrollIdx;
}
</script>
</head>
<body onscroll="scrollListener()">
<iframe src="test.html" height="300" width="100%" > </iframe>
<div style="height: 99999px;" id="demo">test</div>
</body>
</html>
<html>
<head>
<title>子窗口</title>
</head>
<body onmouseover="window.parent.keepScroll();test.innerHTML='over'" onmouseout="window.parent.scrollListener();test.innerHTML='out'">
<div id="test"></div>
</body>
</html>
<html>
<head>
<title></title>
</head>
<body>
<iframe src="test.html" height="100" width="100%" > </iframe>
<p style="height: 99999px;">test</p>
</body>
</html>
<html>
<head>
<title>子窗口</title>
<script type="text/javascript">
var tmp;
function over(){
var p=window.parent;
tmp=p.document.body.offsetWidth-p.document.body.clientWidth+6;
p.document.body.style.marginRight=tmp;
p.document.body.style.overflow='hidden';
}
function out(){
var p=window.parent;
p.document.body.style.marginRight="";
p.document.body.style.overflow='';
}
</script>
</head>
<body onmouseover="over();" onmouseout="out();">
</body>
</html>