刷新 iframe 而不重定向父页面
Refresh iframe without redirecting parent page
我有网站A,我将其嵌入到网站B的iframe中.网站A有一个下拉菜单,可以从中更改网站的语言。
问题:当我从 iframe 内部的下拉菜单更改语言时,整个父窗口重定向到网站 A。我希望刷新 iframe 并更改语言,但不要将父窗口重定向。以下是 iframe 当前嵌入方式的 html:
<iframe src="xxx" scrolling="no" frameborder="no" align="center" height = "600" width = "940">
</iframe>
我尝试使用 iframe 沙盒属性,结果如下:
sandbox="允许表单允许脚本" - 父页面不会重定向,iframe在单击下拉菜单后显示空白页面
sandbox="allow-forms allow-scripts allow-same-origin" - 同上
sandbox="允许表单允许脚本允许同源允许顶部导航" - 页面重定向为没有沙盒属性
对于前两个,我还从控制台注意到我收到以下消息:
不安全的 JavaScript 尝试从具有 URL "yyy"的框架启动对带有 URL "xxx"的框架的导航。尝试导航顶级窗口的框架已沙盒化,但未设置"允许顶部导航"标志。
这是否表明要解决此问题,我必须更改iframe内部页面上的某些内容,而不是父页面?有什么想法吗?
您是否尝试过在更改选择值时target
属性设置为_self
?
即...页 A:
VARS: <script>document.write(document.location.search)</script><br>
<br>
<form name="f" target="_self">
<select id="langSelect" name="langSelect" onChange="document.f.submit()">
<option value="">...please select...</option>
<option value="en">English</option>
<option value="es">Spanish</option>
</select>
</form>
页 B:
This if page B...<br>
<br>
This is iframe A:<br>
<iframe src="A.html"></iframe>
相关文章:
- 重定向iFrame中的父URL
- 如果页面为iframe,则重定向
- 附加'沙箱'属性设置为动态创建的iframe以停止重定向
- Iframe提交并将用户重定向回原始页面,但Iframe似乎仍然存在
- 在不使用 JavaScript 的情况下通过 iframe 访问时从页面重定向
- 由 URL 触发的来自 iFrame 的 JavaScript 重定向
- 读取iframe重定向(同一域)
- 在iFrame内部保持重定向
- js重定向,如果不在fb iframe中
- 停止重定向嵌入的iframe
- 移动设备上的 iFrame 重定向主页问题
- 根据文本框中的值范围重定向到 iframe 中的 URL
- 从外部 iFrame 重定向和链接中删除历史记录
- 刷新 iframe 而不重定向父页面
- 使用 javascript 从 MVC Action 通过 iFrame 重定向到父级
- 使用 Javascript/jQuery 重定向时将 POST 数据发送到顶级 iframe
- 使用目标从弹出窗口在 safari 中发布和重定向 iframe
- 窗口位置 阻止 iframe 重定向父窗口
- 表单提交后重定向iframe
- 如何重定向Iframe到另一个URL php