如何模拟div的点击,然后以编程方式在webview中触发onclick事件? [英] How do I emulate a click on a div then fire the onclick event in webview programmatically?

查看:185
本文介绍了如何模拟div的点击,然后以编程方式在webview中触发onclick事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是JavaScript的新手,刚刚创建了一个嵌入了webView的可可应用程序,其中显示了Gmail iPhone网站。我要在这里做的是安排一个计时器方法,然后在计时器方法中,模拟单击刷新按钮以触发on单击事件?

I am new to JavaScript, just created a cocoa app with a webView embedded which display the gmail iPhone site. What I want to do here is to schedule a timer method, then in the timer method,emulate a click on a refresh button to fire the on click event?

推荐答案

Dom事件可以被调用而触发:

Dom events can be fired just calling it:

下面的代码将触发ID为'#foo'的元素的click事件。

The code below will fire the click event of the element with the id '#foo'

document.getElementByTagName('foo').onclick();

这篇关于如何模拟div的点击,然后以编程方式在webview中触发onclick事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆