防止 iframe 的链接重定向父级页面
项目中发现,多系统通过iframe嵌套时,如果iframe的请求是重定向会导致父级页面重定向,怎么破?
查找MDN(https://developer.mozilla.org/zh-CN/docs),找到sandbox 属性是用来限制安全沙箱的.

最终的设置
(不包含allow-top-navigation即可)
1、在 PC 端你可以这样设置 iframe, 来防止父级页面被重定向, 产生重定向结果的链接会以 _blank 的形式打开
<iframe src="page-b.html" sandbox="allow-forms allow-scripts allow-same-origin allow-popups"></iframe>
2、在移动端你需要这样设置 iframe, 让产生重定向结果的链接失效, 来达到防止父级页面被重定向的目的
<iframe src="page-b.html" sandbox="allow-forms allow-scripts allow-same-origin"></iframe>
防止 iframe 的链接重定向父级页面的更多相关文章
- 解决iframe重定向让父级页面跳转
原文:http://www.jb51.net/article/40583.htm 有内嵌iframe的页面,当session过期时,点击连接重定向后的跳转会在iframe中跳转,在登录页面中加入下面的 ...
- JS 的子父级页面调用
window.frames["iframevehquery"].add(); // 父页面调用嵌套子页面的js函数, iframevehquery 为 iframe 的name值, ...
- 使用jquery刷新当前页面、刷新父级页面
如何使用jquery刷新当前页面 下面介绍全页面刷新方法:有时候可能会用到 window.location.reload(); //刷新当前页面.(我用的这个一个,非常好) parent.locati ...
- js 取父级 页面上的元素
var bb=window.opener.frames["contentIframe"].document.all["my:费用类别"][0].value; / ...
- 页面单击按钮弹出modaldialog然后调用ajax处理程序获取数据,给父级页面控件赋值
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="RefTopicList.asp ...
- Flutter路由跳转父级页面向子页面传参及子页面向父级页面传参
Flutter中页面通过路由跳转传参主要分两种,一种是通过push()跳转时根据设定的参数进行传参,另一种是通过pop()返回时进行传参. 父级页面向子页面push()传参 假设从A页面跳到B页面可能 ...
- VUE调用子窗口弹窗或组件弹窗,关闭弹窗刷新父级页面主页面,通过this.$emit来实现
this.$emit是父级向自己传值 第一步在父级页面创建自己页面的引用 <template> <div> <edit ref="edit" @ref ...
- 关于iframe里的子页面如何调取父级页面里的事件(子调父)
在子页面里面的事件里写 self.parent.window.父级函数名('参数名'); 父级里面直接写函数. js中的parent.top.self的含义. js中经常看到window.parent ...
- iframe 跨域调用父级方法的方案
一.如果高层域名相同的话,可以通过document.domain来实现跨域访问 例如: 父级域名:localhost:8080 子级域名:localhost:9090 那么可以设置document.d ...
随机推荐
- POJ1523 SPF 单点故障
POJ1523 题意很简单,求删除割点后原先割点所在的无向连通图被分成了几个连通部分(原题说prevent at least one pair of available nodes from bein ...
- handy源码阅读(五):PollerBase类
使用poll内核函数等待事件发生: struct PollerBase: private noncopyable { int64_t id_; int lastActive_; PollerBase( ...
- CF1244C
题目描述 给出n,p,w,d,求(x,y,z)使得 xw+yd=p x+y+z=n 其中d<w<10^5^ 题解 显然扩欧啊( 来自天国的long long y如果大于等于w,则显然可以把 ...
- js 将时间戳转为日期格式
最近项目需要在前端将一个13位的时间戳显示成日期格式,在网上查了很多都不符合要求,只有一个是能满足要求的,在这记录一下,说不定以后还用的着. 13位时间戳改为yyyy-MM-dd HH-mm-ss 格 ...
- jq刷新页面
//页面加载时绑定按钮点击事件$(function(){ $("#按钮id").click(function(){ refresh(); });});// ...
- 算法题常见的BUG错误(总结)
1. 快排的partition if(l >= r) return ; int i = l, j = r; int tmp = v[i]; while(i < j) { while(i & ...
- python魔法属性
1.__doc__:表示类的描述信息 class Person(object): '''定义人的类''' def func(self): pass print(Person.__doc__) 结果为: ...
- IOC和AOP使用扩展之AOP详解实现类
摘要: “Depend on yourself” is what nature says to every man. Parents can help you. Teachers can hel ...
- 大数据笔记(十)——Shuffle与MapReduce编程案例(A)
一.什么是Shuffle yarn-site.xml文件配置的时候有这个参数:yarn.nodemanage.aux-services:mapreduce_shuffle 因为mapreduce程序运 ...
- hyperworks2019x中模型简化
Defeature→Fillets