"top.location.href"是最外層的頁面跳轉
"window.location.href"、"location.href"是本頁面跳轉
"parent.location.href"是上一層頁面跳轉.
location是window對象的屬性,而所有的網頁下的對象都是屬於window作用域鏈中(這是頂級作用域),所以使用時是可以省略window。而top是指向頂級窗口對象,parent是指向父級窗口對象。
window.location是window對象的屬性,而window.open是window對象的方法
window.location是你對當前瀏覽器窗口的URL地址對象的參考!
window.open是用來打開一個新窗口的函數!
window.open()是可以在一個網站上打開另外的一個網站的地址
而window.location()是只能在一個網站中打開本網站的網頁
window.location或window.open如何指定target?
這是一個經常遇到的問題,特別是在用frame框架的時候
解決辦法:
window.location 改為 top.location 即可在頂部鏈接到指定頁
或
window.open("你的網址","_top");
<input type="button" value="新窗口打開" onclick="window.open('http://www.baidu.com')">
<input type="button" value="當前頁打開" onclick="top.location='http://www.baidu.com','_top'">
window.location.href = "C.html"