簡體   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