天天看點

關于js中"window.location.href"、"location.href" 等如何跳轉

關于js中"window.location.href"、"location.href"、"parent.location.href"、"top.location.href"的用法

"window.location.href"、"location.href"是本頁面跳轉

"parent.location.href"是上一層頁面跳轉

"top.location.href"是最外層的頁面跳轉

舉例說明:

如果A,B,C,D都是jsp,D是C的iframe,C是B的iframe,B是A的iframe

頁面關系如圖:

如果D中js這樣寫

"window.location.href"、"location.href":D頁面跳轉

"parent.location.href":C頁面跳轉

"top.location.href":A頁面跳轉

如果D頁面中有form的話,

<form>: form送出後D頁面跳轉

<form target="_blank">: form送出後彈出新頁面

<form target="_parent">: form送出後C頁面跳轉

     本文轉自布拉君君 51CTO部落格,原文連結:http://blog.51cto.com/5148737/1568716,如需轉載請自行聯系原作者