昨日代码,记录代码片断
Tech
Css
DHTML
ASP
PHP
MSSQL
MYSQL
VC++
VB
小常识
程序源码
常用工具
网络安全
英语知识
英语学习资料
您的位置:
Home
>>
DHTML
用JS控制IFRAME的内容页面左右滚动
<iframe name= "iframe1" style= "width:100;height:100 " src="ads/personal-lawyer.htm"> </iframe> <br> <input name= "button1" type= "button" value= "左 " onclick=showLeft()> <input name= "button1" type= "button" value= "右 " onclick=showRight()> <input name= "button1" type= "button" value= "上 " onclick=showTop()> <input name= "button1" type= "button" value= "下 " onclick=showDown()> <script language=javascript> function showLeft(){ if(iframe1.document.body.scrollLeft> 0) iframe1.document.body.scrollLeft=parseInt(iframe1.document.body.scrollLeft)-10; } function showRight(){ if(iframe1.document.body.scrollLeft <iframe1.document.body.scrollWidth) iframe1.document.body.scrollLeft=parseInt(iframe1.document.body.scrollLeft)+parseInt(10); } function showTop(){ if(iframe1.document.body.scrollTop> 0) iframe1.document.body.scrollTop=parseInt(iframe1.document.body.scrollTop)-10; } function showDown(){ if(iframe1.document.body.scrollTop <iframe1.document.body.scrollWidth) iframe1.document.body.scrollTop=parseInt(iframe1.document.body.scrollTop)+parseInt(10); } </script>
[提示:你可先修改部分代码,再按运行]
代码CODE 备案编号:
吉ICP备2022000970号-1