webbrowser 自动滚动网页
2015-09-12 11:22
344 查看
public partial class Form1 : Form { int current = 0; Timer timeDown = new Timer(); Timer timeUp = new Timer(); public Form1() { InitializeComponent(); webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted); webBrowser1.Navigate("http://www.yahoo.com.cn"); timeDown.Interval = 100; timeDown.Tick += new EventHandler(timeDown_Tick); timeUp.Interval = 100; timeUp.Tick += new EventHandler(timeUp_Tick); } void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { current = 0; timeDown.Enabled = true; } void timeDown_Tick(object sender, EventArgs e) { HtmlDocument doc = webBrowser1.Document; int height = webBrowser1.Document.Body.ScrollRectangle.Height; current += height / 100; if (current >= height) { current = height; timeDown.Enabled = false; timeUp.Enabled = true; } doc.Window.ScrollTo(new Point(0, current)); } void timeUp_Tick(object sender, EventArgs e) { HtmlDocument doc = webBrowser1.Document; int height = webBrowser1.Document.Body.ScrollRectangle.Height; current -= height / 100; if (current <= 0) { current = 0; timeUp.Enabled = false; } doc.Window.ScrollTo(new Point(0, current)); } }
相关文章推荐
- Xcode添加空模板的路径
- 经纪xx系统节点VIP案例介绍和深入分析异常
- Android简易数据存储之SharedPreferences
- hdu 5291 dp+优化 ****
- MacBook常见的问题及解决方法
- python-04<关于字典:键必须是可哈希的>
- Nginx基础. Nginx通配散列表
- Nginx基础. Nginx基本哈希构成
- POJ 1423:Big Number 求N的阶乘的长度 斯特林公式
- Codeforces Gym 100548F Color (组合数+容斥)
- javascript仿天猫加入购物车动画效果
- POJ 1423:Big Number 求N的阶乘的长度 斯特林公式
- JavaScript获取onclick、onchange等事件值的代码
- 实用,为什么这样的一个数组?
- $PATH环境变量相关知识
- Oracle中的PLsql的符号解释大全
- JSON数据解析
- ajax提交表单
- HDU1213——How Many Tables(并查集)
- Servlet学习笔记之ServletDemo