更新时间:2023-11-25 16:34:34
我和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.