更新时间:2023-11-25 17:18:28
我在使用 jQuery Thickbox(一个灯箱样式的对话框小部件)时遇到了类似的问题.我解决问题的方法如下:
I had a similar problem with the jQuery Thickbox (a lightbox-style dialog widget). The way I fixed my problem is as follows:
function setFocusThickboxIframe() {
var iframe = $("#TB_iframeContent")[0];
iframe.contentWindow.focus();
}
$(document).ready(function(){
$("#id_cmd_open").click(function(){
/*
run thickbox code here to open lightbox,
like tb_show("google this!", "http://www.google.com");
*/
setTimeout(setFocusThickboxIframe, 100);
return false;
});
});
如果没有 setTimeout(),代码似乎无法工作.根据我的测试,它适用于 Firefox3.5、Safari4、Chrome4、IE7 和 IE6.
The code doesn't seem to work without the setTimeout(). Based on my testing, it works in Firefox3.5, Safari4, Chrome4, IE7 and IE6.