本人遇到一个难题,跪求答案,请各位高手们帮忙,问题如下:点击 http://www.qq.com/index.htm上的一个连接(连接打开网站www.baidu.com)现在的问题是:
1.点击连接打开 www.baidu.com 的同时,怎么让 www.qq.com/index.htm这个页面也转向新的网址www.sina.com注:http://www.qq.com/index.htm 上的连接是固定指向www.baidu.com这个网址的改不了 (因为在QQ做的广告连接不是咱们要改就能改的)
1.点击连接打开 www.baidu.com 的同时,怎么让 www.qq.com/index.htm这个页面也转向新的网址www.sina.com注:http://www.qq.com/index.htm 上的连接是固定指向www.baidu.com这个网址的改不了 (因为在QQ做的广告连接不是咱们要改就能改的)
<script type="text/javascript" >
function init(){
var aElms = document.getElementsByTagName("a");
for(var i=0;i<aElms.length;i++){
aElms[i].addEventListener('click',goUrl,false)
}
}
function goUrl(){
document.location.href='http://www.sina.com';
}
</script>
<body onload="init()">
<a href="http://www.baidu.com" target="_blank">1111</a><br>
<a href="http://www.baidu.com" target="_blank">2222</a><br>
<a href="http://www.baidu.com" target="_blank">3333</a><br>
<a href="http://www.baidu.com" target="_blank">4444</a><br>
<a href="http://www.baidu.com" target="_blank">5555</a><br>
<a href="http://www.baidu.com" target="_blank">6666</a><br>
<a href="http://www.baidu.com" target="_blank">7777</a><br>
<a href="http://www.baidu.com" target="_blank">8888</a><br>
<a href="http://www.baidu.com" target="_blank">9999</a><br>
<a href="http://www.baidu.com" target="_blank">0000</a><br>
</body>
</html>
<script type="text/javascript" >
function init(){
var aElms = document.getElementsByTagName("a");
for(var i=0;i<aElms.length;i++){
try{
aElms[i].addEventListener('click',goUrl,false)
}catch(e){
aElms[i].attachEvent('onclick', goUrl);
}
}
}
function goUrl(){
document.location.href='http://www.sina.com';
}
</script>
<body onload="init()">
<a href="http://www.baidu.com" target="_blank">1111</a><br>
<a href="http://www.baidu.com" target="_blank">2222</a><br>
<a href="http://www.baidu.com" target="_blank">3333</a><br>
<a href="http://www.baidu.com" target="_blank">4444</a><br>
<a href="http://www.baidu.com" target="_blank">5555</a><br>
<a href="http://www.baidu.com" target="_blank">6666</a><br>
<a href="http://www.baidu.com" target="_blank">7777</a><br>
<a href="http://www.baidu.com" target="_blank">8888</a><br>
<a href="http://www.baidu.com" target="_blank">9999</a><br>
<a href="http://www.baidu.com" target="_blank">0000</a><br>
</body>
</html>
注:http://www.qq.com/index.htm 上的连接是固定指向www.baidu.com这个网址的改不了 (因为在QQ做的广告连接不是咱们要改就能改的)