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