admin管理员组文章数量:1434916
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?
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?
Share Improve this question edited Mar 7, 2020 at 6:26 Cœur 38.8k25 gold badges206 silver badges279 bronze badges asked Apr 18, 2011 at 9:47 NeXT5tepNeXT5tep 8811 gold badge11 silver badges24 bronze badges2 Answers
Reset to default 3Dom events can be fired just calling it:
The code below will fire the click event of the element with the id '#foo'
document.getElementByTagName('foo').onclick();
Thats really simple, you should have written a function to do the refresh activity and just put that function inside setInterval,
Syntax: setInterval(code,millisec,lang)
where,
code - A reference to the function or the code to be executed
millisec - The intervals (in milliseconds) on how often to execute the code
lang -(Optional) JScript | VBScript | JavaScript
For Example,
function refreshIphoneStuff(){
//Your code here
}
You can call this function based on the time like the one below,
window.setInterval("refreshIphoneStuff()",1000); //This will call that function for every 1 sec.
Hope this helps!
Update:
If the page is created by you (i.e) the refresh functionality is created by you then you can attach a handler on the image like,
<img src='pathtorefreshbuttonimage/refresh.gif' onclick="refreshIphoneStuff();">
(or) if its purely from gmail side then you must use some webdeveloper tools like firebug or webdeveloper toolbar to guess which function is called on click of refresh.
Hope this will clear your issues!
本文标签:
版权声明:本文标题:javascript - How do I emulate a click on a div then fire the onclick event in webview programmatically? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745632259a2667345.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论