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; 
复制代码
相关文章
相关标签/搜索