繁体   English   中英

刷新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 =“ allow-forms allow-scripts”-父页面不会重定向,iframe在单击下拉菜单后会显示空白页面

sandbox =“ allow-forms allow-scripts allow-same-origin”-与上述相同

sandbox =“ allow-forms allow-scripts allow-same-origin allow-top-navigation”-页面重定向为无沙箱属性

对于前两个,我还从控制台注意到我收到了以下消息:

不安全的JavaScript尝试从URL'yyy'的框架启动URL'xxx'的导航。 试图浏览顶级窗口的框架已被沙箱化,但是未设置“ allow-top-navigation”标志。

这是否表明要解决此问题,我必须在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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM