iframe實現子頁面內跳轉到整個頁面

問題描述:

頁面內嵌iframe時,實現子頁面內點擊跳轉是整個頁面的跳轉,而不是在子頁面內跳轉。html

問題解決方法:

  • 方法一:

  若是你的頁面跳轉是使用的<a></a>標籤,只需在 a 標籤中添加 "target="_parent" 屬性便可。bash

  • 方法二:  url

    在head標籤之間加入<base target="_parent" /> 。則子頁面內的全部跳轉默認是父頁面一塊兒跳。(注:在子頁面的head標籤中添加哦)spa

  • 方法三:code

  在js中跳轉,window.location.href或者 window.open();由於window這種跳轉是沒有target屬性的,這時,你能夠使用:htm

讓父頁面跟着一塊兒跳轉,即在get

window.location.href=url後面加上window.parent.location.href=url;iframe

例如:io

window.location.href=http://www.a.html?window.parent.location.href=http://www.a.html; 
複製代碼
相關文章
相關標籤/搜索