javascript - 刷新iframe而不影响没有iframe id的父页面

标签 javascript html iframe

我在索引页中使用了 2 个 Iframe。如果从任何 iframe 中首选任何操作,则它必须单独重新加载该 iframe。但它覆盖了我的索引页面作为 Iframe URL 之一。谁能帮我解决这个问题。

我的预期结果在 Chrome 中有效,但在 Internet Explorer 中无效

注意:iframe id 和名称自动生成

我使用下面的命令来刷新 Iframe 窗口

window.location.reload(true)

window.top.location.reload(true)

screen reference

最佳答案

尝试重新加载特定的 iframe 元素,因为您现在可能正在重新加载整个页面(窗口)。

1- 首先,您必须使用 name 属性为每个 iframe 取名。

2- 稍后尝试使用 javascript 函数 document.getElementsByName("IframeName") 来检索特定的 Iframe。之后,您可以使用生成的对象(Iframe)来应用您需要的更改(更改 src 属性)。

重要提示:请记住,并非所有浏览器和 HTML5 都支持 iframe。

希望对你有帮助...

关于javascript - 刷新iframe而不影响没有iframe id的父页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59587875/

相关文章:

java - 在方法调用期间引发 Cordova Android iframe Java 异常

javascript - 如何在不使用背景颜色的情况下用颜色填充 div?

javascript - 检测页面是否在 iframe 内并获取 iframe id

javascript - 使用 Vue.js 将数组长度增加和减少到输入范围值

html - "Fog over"图像无处不在,但在带有 CSS 的 div 下

javascript - 在javascript中将字符串转换为onclick处理程序

asp.net-mvc - 带有 ASP.NET MVC 的 HTML5

html - CSS - 嵌入式 iframe 上的半径不起作用

javascript - 有没有办法在不使用 React 或 Vue 的情况下使用裁剪框在 JavaScript 中裁剪视频?

Emacs 中的 Javascript 主要模式