iframe 标签相对路径导致页面重复加载问题解决方案
代码中的问题在于 iframe 标签使用了相对路径 'index.html' 作为 src 属性的值。这会导致两个 'index.html' 页面同时加载,一个是外层的页面,一个是 iframe 中的页面。
要解决这个问题,可以使用绝对路径或者相对于根目录的路径来指定 src 属性的值。例如,可以使用 '/index.html' 来代替 'index.html',这样就可以确保只加载一个 'index.html' 页面。
修改后的代码如下:
<iframe name='my-iframe' src='/index.html' frameborder='0' style='width: 100%; height: 100%;'></iframe>
原文地址: https://www.cveoy.top/t/topic/p5pB 著作权归作者所有。请勿转载和采集!