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

Javascript
javascript 支持链式调用的异步调用框架Async.Operation
JavaScript 异步调用框架 (Part 6 - 实例 & 模式)
让JavaScript 轻松支持函数重载 (Part 1 - 设计)
让 JavaScript 轻松支持函数重载 (Part 2 - 实现)
javascript dragable的Move对象
同一个表单 根据要求递交到不同页面的实现方法小结
Extjs ajax同步请求时post方式参数发送方式
实现连缀调用的map方法(prototype)
javascript Array.remove() 数组删除
asp(javascript)全角半角转换代码 dbc2sbc
jquery select(列表)的操作(取值/赋值)
JavaScript 乱码问题
js正确获取元素样式详解
JQuery 小练习(实例代码)
JavaScript 的方法重载效果
JavaScript 变量作用域及闭包
jQuery 解析xml文件
javascript 当前日期加(天、周、月、年)
Javascript+XMLHttpRequest+asp.net无刷新读取数据库数据
上传图片时JS自动显示图片

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 339 ::
收藏到网摘: 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>