防止iframe窃取焦点 [英] Prevent an iframe from stealing focus
问题描述
我有一个嵌入了iframe的网站。当我测试iframe时,我使用google.com并注意到搜索输入字段成为焦点。显然,我不会使用google.com进行产品生产,但希望阻止iframe窃取焦点。
有没有一种方法可以防止iframe阻止焦点如果你有权访问服务器端脚本,你可以使用它来下载你想要嵌入的页面的一个实时副本。 ,搜索它并删除任何焦点窃取代码,然后在您的iframe中显示修改后的页面。或者如果你发现没有焦点窃取代码,你可以像往常一样链接你的iframe到远程页面。
另一种选择可能是最初隐藏iframe与CSS style =display:none
并允许用户使用javascript Object.style.display =inline
I have a website that embeds an iframe. When I was testing the iframe, I used google.com and noticed the search input field took focus. Clearly, I won't be using google.com for production but would like to prevent the iframe from stealing focus.
Is there a way to prevent an iframe from stealing focus?
If you have access to server side scripting you can use it to download a live copy of the page you want to embed, search it and remove any focus stealing code, then display that modified page in your iframe. Or if you find there is no focus stealing code, you can just link your iframe to the remote page as usual.
Another option might be to initially hide the iframe with CSS style="display:none"
and allow the user to unhide it with javascript Object.style.display="inline"
这篇关于防止iframe窃取焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!