以下代码第一次加载页面时,但是当使用F5刷新页面时,它在firefox上不起作用。在chrome中它可以正常工作。
$(document).ready(function() {
$("iframe").each(function() {
// Using closures to capture each one
var iframe = $(this);
iframe.on("load", function() { // Make sure it is fully loaded
iframe.contents().click(function(event) {
iframe.trigger("click");
});
});
iframe.click(function() {
alert("Clicked...");
});
});
});
答案 0 :(得分:-2)
将所有代码放在jQuery(function(){
//here
})
中,一切都会好的。运行页面加载,每个f5操作,删除其他代码以测试重新加载。