<
script type
=
"
text/javascript
"
>
function
goUrl(x)
{
window.location.href
=
x;
}
<
/
script>
<
a href
=
"
javascript:;
"
onclick
=
"
javascript:goUrl('http://www.sina.com');
"
>
跳轉1
<
/
a>
<
a href
=
"
javascript:void(0);
"
onclick
=
"
javascript:goUrl('http://www.sina.com');
"
>
跳轉2
<
/
a>
<
a href
=
"
javascript:void(0);
"
onclick
=
"
javascript:goUrl('http://www.sina.com');return false;
"
>
跳轉3
<
/
a>
<
a href
=
"
#
"
onclick
=
"
javascript:goUrl('http://www.sina.com');
"
>
跳轉4
<
/
a>
<
a href
=
"
###
"
onclick
=
"
javascript:goUrl('http://www.sina.com');
"
>
跳轉5
<
/
a>
測試環境IE6,IE7,Firefox 3。 javascript
跳轉1和2在IE6環境下無效,三、四、5在IE6,IE7,Firefox3.01下測試均能 經過,。 java
跳轉4和5最簡潔。 測試
關鍵在於<a>的href屬性,空連接用"#","###"。 spa
爲了避免返回網頁頂端。 ip
空連接推薦用"###"。