时间:2021-07-01 10:21:17 帮助过:10人阅读
<p><a href="javascript:;" onclick="jumpSina()">Sina</a></p>
<p><a href="javascript:void 0;" onclick="jumpSohu()">Sohu</a></p>
<script>
function jumpSina() {
location.href = 'http://www.sina.com.cn'
}
function jumpSohu() {
location.href = 'http://www.sohu.com'
}
</script>
IE6中点击链接无法跳转,其它浏览器都可以。解决方法是改成锚点,
代码如下:
<p><a href="###" onclick="jumpSina()">Sina</a></p>
<p><a href="#none" onclick="jumpSohu()">Sohu</a></p>
<script>
function jumpSina() {
location.href = 'http://www.sina.com.cn'
}
function jumpSohu() {
location.href = 'http://www.sohu.com'
}
</script>
如果把跳转方式改为window.open,则IE6下没有问题,如下
代码如下:
<p><a href="javascript:;" onclick="jumpSina()">Sina</a></p>
<script>
function jumpSina() {
window.open( 'http://www.sina.com.cn')
}
</script>