0
我有我的网页上的JavaScript函数,我在显示一个UIWebView:在一个UIWebView点击锚与一个UIButton
$(document).ready(function() {
// index to reference the next/prev display
var i = 0;
// get the total number of display sections
// where the ID starts with "display_"
var len = $('div[id^="hl"]').length;
// for next, increment the index, or reset to 0, and concatenate
// it to "display_" and set it as the hash
$('#next').click(function() {
++i;
window.location.hash = "hl" + i;
return false;
});
// for prev, if the index is 0, set it to the total length, then decrement
// it, concatenate it to "display_" and set it as the hash
$('#prev').click(function() {
if (i > 1)
--i;
window.location.hash = "hl" + i;
return false;
});
});
所以我需要做的是模拟锚点击时,我的UIButton点击:
- (IBAction)next:(id)sender {
[animalDesciption stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"next\").click();"];
}
但这不起作用! 只需点击具有“next”标识的锚点,它就可以在HTML页面上很好地工作。
任何想法,为什么这不起作用,当点击按钮?
顺便说一句我可以用我当前的设置调用标准的JavaScript函数,如myFunc()
,但它不会做这样的事情!
任何想法将不胜感激!
这工作很好! – 2012-04-20 19:28:45