我现在是通过JQuery的笨方法实现的如:
$("#div_Preview_Content *").each(function () {
$(this).removeAttr("onblur");
$(this).removeAttr("onclick");
$(this).removeAttr("ondblclick");
$(this).removeAttr("onfocus");
$(this).removeAttr("onkeydown");
$(this).removeAttr("onkeypress");
$(this).removeAttr("onkeyup");
$(this).removeAttr("onmousedown");
$(this).removeAttr("onmouseout");
$(this).removeAttr("onmousemove");
$(this).removeAttr("onmouseover");
$(this).removeAttr("onmouseup");
});但是这样的实现方式,性能明显达不到要求谁能提供更好的实现或思路吗?
$("#div_Preview_Content *").each(function () {
$(this).removeAttr("onblur");
$(this).removeAttr("onclick");
$(this).removeAttr("ondblclick");
$(this).removeAttr("onfocus");
$(this).removeAttr("onkeydown");
$(this).removeAttr("onkeypress");
$(this).removeAttr("onkeyup");
$(this).removeAttr("onmousedown");
$(this).removeAttr("onmouseout");
$(this).removeAttr("onmousemove");
$(this).removeAttr("onmouseover");
$(this).removeAttr("onmouseup");
});但是这样的实现方式,性能明显达不到要求谁能提供更好的实现或思路吗?
然后页面指过去
两边加上注释代码
这样就算调用也找不到函数了吧。
如果你是使用添加事件监听attachEvent\addEventListener,那么你移除脚本就remove一下事件。
1.通过URL获取指定页面源文件的 HTML 字符串(已实现)
2.去除HTML字符串中的所有JS脚本(已实现)和JS调用(已实现,但是速度不理想),此步骤为了第3步
3.正确的在自己的页面的指定层中展示就是这样...继续等...
window.onerror=function(ex){
//alert('myex:'+ex);
return true;
}
</script>
在开始加这样个js看看
那就不要用jqeury。直接用js写。//类似这样写:
便利div_Preview_Content的所有子元素div_Preview_Content.onclick=null;
div_Preview_Content.onxxxx=null;....回答问题要查资料?用《Csdn收音机》可以最快速度搞定!
$("#div_Preview_Content *").each(function(){});
这里迭代的是一个页面的所有标签
随便也有几百上千吧
有这么多哦吗?就算有效率也不会有很大问题。几百几千对计算机来说根本没感觉才对的。你应该确认一下,效率的瓶颈是不是因为这个。
建议如果是对页面上的所有控件的话,可以用for(var i=0;i<body.all.length;i++){
}这样遍历效率会比较高。问题的保姆,帖子的管家——《Csdn收音机》!
如果是的话,就把前面覆盖一个透明div就可以了。让鼠标无法作用。
需要注意的是,在IE里,没有内容的DIV是不能覆盖内容的,需要设置透明滤镜。
我把$("#div_Preview_Content *").each(function(){...});
注释掉后,功能刷刷的快
取消注释后,功能总是会停顿那么0点几秒的我需要的是在自己页面的一个层上显示任意页面的经过处理的HTML源
处理后的body是不存在的
这个应该尝试更精确点,确保div_Preview_Content *里面没有太多不需要处理的内容。removeAttr罗列使用次数过多了,这种情况下也会影响性能,应使用属性列表的方法进行操作。而removeAttr本身只支持单独的属性,那就换换,用attr,它可以一次操作多个属性,明白了吧。