Open yang-mr opened 5 years ago
把你代码,发给我看看
var del_times = 0, deTimer = null;
function adGo() {
var iframe = document.getElementsByTagName('iframe')[0];
if(iframe){
console.log(iframe)
var bodyNode = {tagName:''}, iframeParent, targetNode = iframe.parentNode;
while (bodyNode.tagName != 'BODY'){
bodyNode = targetNode;
if(bodyNode.tagName != 'BODY'){
iframeParent = targetNode;
targetNode = targetNode.parentNode;
}
}
if(iframeParent) //如果iframe有父类
bodyNode.removeChild(iframeParent);
else
bodyNode.removeChild(iframe);
}
del_times++;
//这里是执行50次, 每次200ms, 意思在10秒以内删除垃圾广告。
if (del_times > 50) window.clearInterval(deTimer)
}
//抢先 删除 嵌入广告
(function(){adGo();}())
deTimer = self.setInterval(adGo, 200);
这个我知道啊,我所指的是html的部分~~
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
`<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page trimDirectiveWhitespaces="true" %> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
兄弟人呢?
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.