当前位置: 首页 > 图文教程 > 网络编程 > Javascript > 用javascript控制iframe滚动的代码

Javascript
Mootools 1.2教程 排序类和方法简介
Mootools 1.2 手风琴(Accordion)教程
Mootools 1.2教程 类(一)
Mootools 1.2教程 Tooltips
Mootools 1.2教程 选项卡效果(Tabs)
Mootools 1.2教程(21):类(二)
Mootools 1.2教程 同时进行多个形变动画
Mootools 1.2教程 滑动效果(Slide)
不安全的常用的js写法
javascript 检测浏览器类型和版本的代码
javascript 弹出层居中效果的制作
javascript 遮照层效果
Javascript createElement和innerHTML增加页面元素的性能对比
颜色快速采集器javascript代码
var与Javascript变量隐式声明
javascript 面向对象编程 万物皆对象
jQuery 事件队列调整方法
JavaScript switch case 的用法实例[范围]
控制input的CSS但不影响CheckBox以及Radio的样式
ext 同步和异步示例代码

Javascript 中的 用javascript控制iframe滚动的代码


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 304 ::
收藏到网摘: n/a

现在有一个横向的IFRAME,需要通过点击iframe外的一个图片来横向滚动iframe内的一个html页,但又不想让看见iframe的滚动条,请问如何解决啊????
<img src="demo.gif" onmousedown="window.timer=setInterval('a.document.body.scrollTop++',10)" onmouseup="clearInterval(window.timer)">
<img src="demo.gif" onmousedown="window.timer=setInterval('a.document.body.scrollTop--',10)" onmouseup="clearInterval(window.timer)">
<iframe name=a src="test.html" scrolling=no></iframe>

demo.htm
<iframe name="in" src="in.htm"></iframe>
<div align="center" style="height:130px;width:243px;">
<script>var timer;</script>
<br>
<input type="button" value="up"
onmousedown="timer1=setInterval('parent.frames[\'in\'].scrollBy(0,-1)',10)"
onmouseup="clearInterval(timer1)">
<input type="button" value="down"
onmousedown="timer1=setInterval('parent.frames[\'in\'].scrollBy(0,1)',10)"
onmouseup="clearInterval(timer1)" >
</div>

in.htm
<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<br>0<

横向滚动..
demox.htm
<iframe name="in" src="inx.htm"></iframe>
<div align="center" style="height:130px;width:243px;">
<script>var timer;</script>
<br>
<input type="button" value="Left"
onmousedown="timer1=setInterval('parent.frames[\'in\'].scrollBy(-1,0)',10)"
onmouseup="clearInterval(timer1)">
<input type="button" value="Right"
onmousedown="timer1=setInterval('parent.frames[\'in\'].scrollBy(1,0)',10)"
onmouseup="clearInterval(timer1)" >
</div>

inx.htm
<body scroll=no>