当我点击链接时,它会在 Firefox、Opera Mini 中打开两个弹出窗口……还有其他方法吗?
<script type="text/javascript">
window.onload=function() {
var links = document.getElementsByTagName("a");
for(var i=0; i<links.length; i++) {
var string = links[i].href; //href value
var str = string;
var spl = string.split("/");
switch(spl[2])
{
case 'www.google.com':
var str1 = "http://yahoo.com";
links[i].target="_blank";
links[i].href = links[i].addEventListener("click", function(){var windowObjectReference = window.open(str1)}, false);
break;
default:
links[i].target="_blank";
links[i].href= string;
}
}
}
</script>
<a href="http://www.google.com/" target="-blank">www.google.com</a></br>