1、跳轉(zhuǎn)鏈接 在當(dāng)前窗口打開(kāi)
window.location.href="http://www.uoqphhl.cn"
等價(jià)于
<a href="juyiweb.com" target="_self">go juyi</a>
2、跳轉(zhuǎn)鏈接 在新窗口打開(kāi)
window.open("http://www.uoqphhl.cn")
等價(jià)于
<a href="juyiweb.com" target="_blank">go baidu</a>
3、跳轉(zhuǎn)鏈接 返回上一頁(yè)
window.history.back(-1);
4、跳轉(zhuǎn)鏈接
self.location.href="juyiweb.com"
self 指代當(dāng)前窗口對(duì)象,屬于window 最上層的對(duì)象。
location.href 指的是某window對(duì)象的url的地址
self.location.href 指當(dāng)前窗口的url地址,去掉self默認(rèn)為當(dāng)前窗口的url地址,一般用于防止外部的引用
top.location.href:為引用test.html頁(yè)面url的父窗口對(duì)象的url
如果你的網(wǎng)頁(yè)地址是:http://www.a.com,別人的是http://www.b.com, 他在他的頁(yè)面用iframe等框架引用你的http://www.a.com,那么你可以用:
if(top.location.href!=self.location.href){
location.;
}
來(lái)轉(zhuǎn)向你的頁(yè)面,top指代的是主體窗口,這里top.location.href返回http://www.b.com;