function handleEvent(aEvent){
// if aEvent is null, means the Internet Explorer event model,
// so get window.event.
var myEvent = aEvent ? aEvent : window.event;
}
function onPageLoad(){
document.getElementById("myDiv").onclick = handleEvent;
} </script>
// if aEvent is null, means the Internet Explorer event model,
// so get window.event.
var myEvent = aEvent ? aEvent : window.event;
}
function onPageLoad(){
document.getElementById("myDiv").onclick = handleEvent;
} </script>
return function () {
WinOpen(As[i].href)
return false;
};
})(i)
然后还要改下e.preventDefault()
if (As[i].href !="" && As[i].parentNode.getAttribute("colspan") == "1") {
As[i].onclick = function (e) {
var e = e || window.event;
WinOpen(this.href);
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
};
}
}function WinOpen(url){
window.open(url, "new");
}
不要轻易下定论。。同学。。FF下。。td的colspan默认是null如果有值比如是1的话,就会通过了<table>
<tr>
<td>
<a href="http://community.csdn.net">csdn</a>
<a href="http://www.google.com">google</a>
<a href="http://www.baidu.com">baidu</a>
</td>
</tr>
</table>
<script type="text/javascript">
window.onload = function () {
var As = document.getElementsByTagName("A"), i = 0;
for(; i < As.length ; i ++) {
if (As[i].href != "" && (!As[i].parentNode.getAttribute("colspan") || As[i].parentNode.getAttribute("colspan") == "1")) {
As[i].onclick = function (e) {
var e = e || window.event;
WinOpen(this.href);
alert(e);
if (e.preventDefault) e.preventDefault();
else e.returnValue = false;
};
}
}
function WinOpen(url){
window.open(url, "");
}
};
</script>
你的程序我没看明白,能解释清楚么
-------------------
to:muxrwc(需时越兔)
谢谢你的帮助,但是这个程序和我以前的依然不能运行,能再帮看一下么?
-------------------
我再解释下,这个程序是修改当前页面的链接,当点击这个连接时,不让他在当前页面进行跳转,而是弹出一个窗口打开这个链接,我的程序在IE下正常运行,但是在FF下依然是在当前页面跳转的,我找到的资料说对onclick事件的修改, FF有不同于IE的方法,例如这样的代码:
if(window.document.all != null)
window.document.attachEvent("onclick", Links_Onclick)
else
window.document.addEventListener("click", Links_Onclick, false);
但我没看明白,我做过测试好像也有问题!
这样看看
你的代码是不是严格按照你那个函数循环和判断来书写的?如果是还有问题。。那可能就是window.onload冲突了。。这样的话你addEventListener一下即可。
用addEventListener的话,怎么使用带参数的函数啊?谢谢了!
wc(参数1, 参数2);
}, false);