location 物件包含目前 URL 的相關資訊。它可以讀取協定、主機、路徑、查詢參數與 hash,也可以用來做頁面跳轉或重新整理。
window.location = "newsview.html?catalogid=1";
若要回到上一頁或下一頁,可使用 history.back、history.forward 或 history.go。
在多框架頁面中,可以用 parent.mainFrame.location 指定框架跳轉,也可以用 DOM 取得 iframe 後變更 src。現代開發中,location 仍常用於路由判斷、參數讀取與重新導向。