我正在搜索代码,将注意力集中在iframe中的文本框上,我找到了像
这样的代码//get the IFRAME element - note no hashes in the name, we're using browser functionality
var iframeRef = document.getElementById("IFRAMEID");
//focus the IFRAME element
$(iframeRef).focus();
//use JQuery to find the control in the IFRAME and set focus
$(iframeRef).contents().find("#CONTROLID").focus();
但很少有人说这段代码不起作用....所以什么是正确的代码。感谢
答案 0 :(得分:1)
只有当您的iframe与父窗口具有相同的域时,它才会起作用。