jQuery 查找并删除 IFrame
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3186051/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Find and remove IFrame
提问by Soarabh
A Iframe is dynamically add just after BODY tag and it breaks my all site, So i want to find IFrame which is just after BODY tag and remove it using JQuery. It also adds some Js so, i want also to remove this. Please help me.
Iframe 是在 BODY 标记之后动态添加的,它破坏了我的所有站点,所以我想找到 BODY 标记之后的 IFrame 并使用 JQuery 将其删除。它还添加了一些 Js,所以我也想删除它。请帮我。
HTML Markup
HTML 标记
<body>
<iframe></iframe>
<script type="text/javascript">
//<![CDATA[
(function(){
var c = document.body.className;
c = c.replace(/no-js/, 'js');
document.body.className = c;
})();
//]]>
</script>
回答by gblazex
var el = document.getElementsByTagName("iframe")[0];
el.parentNode.removeChild(el);
?
or if the #id is static
或者如果 #id 是静态的
$("#conash3D0").remove();
回答by Ritik Khatwani
Instead of just removing it from jquery you need to check the rest of your site. You're a victim of an ifram injection attack. You should check your server and the machines you use to connect to it via FTP for any malware.
您需要检查网站的其余部分,而不仅仅是从 jquery 中删除它。您是 ifram 注入攻击的受害者。您应该检查您的服务器和用于通过 FTP 连接到它的机器是否有任何恶意软件。
Take a look at these:
看看这些:
http://www.diovo.com/2009/03/hidden-iframe-injection-attacks/
http://faiz.kera.la/2009/04/12/server-side-code-cleaner-in-aspnet-for-iframe-injection-attack/
http://www.diovo.com/2009/03/hidden-iframe-injection-attacks/
http://faiz.kera.la/2009/04/12/server-side-code-cleaner-in-aspnet- for-iframe-injection-attack/
回答by Darin Dimitrov
回答by rahul
Try
尝试
$("#conash3D0").remove();