有什么代码能使前边的JS代码无效

来源:百度知道 编辑:UC知道 时间:2024/05/27 04:08:43
比如:<script language="JavaScript">
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
</script><要加的东西>

这个代码是禁用右键的,我在后边加什么能使它无效
不只是指弹出右键,还有很多,比如:
<script>if (top.location != self.location) {top.location=self.location;}</script><要加的东西>
这句是不能使框架的,我要加什么才能使它失效...或加什么才能使前边的代码全失效,有办法吗?

对于不允许复制那个,你只要重新定义就可以覆盖前面的定义。
<script type="text/javascript">
document.onmousedown= new Function("return true;")
document.oncontextmenu = new Function("return true;")
</script>

不过对于后面那个禁止框架的,在代码后面加东西实现起来很困难了,因为代码执行的顺序问题,执行到转向语句之后,页面就开始转向了。

<script language="JavaScript">
function click(e) {
if (document.all) {
if (event.button==2||event.button==3) {
oncontextmenu='return false';
}
}
if (document.layers) {
if (e.which == 3) {
oncontextmenu='return false';
}
}
}
if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;")
fdsafdasfdsa!@@!@#@!#!@//写点乱码 貌似出错了脚本就不会执行了~~
dfs
af
dsa
</script>

不过最好的方法还是逐句重新赋值