如果我有一个 html 文件 A.html
,其中包含从另一个文件夹中的外部 js 文件 A.js
加载的 js 代码。 js 代码创建一个 iframe,其 srcdoc
属性中包含 html
<iframe srcdoc='<script src="file.js"></script>'></iframe>
然后将该 iframe 插入 dom 中。问题是 file.js 相对于哪里?
谢谢
最佳答案
a.html
<iframe srcdoc='<script src="file.js"></script>'></iframe>
文件.js
document.write('fnj');
关于javascript - 在 iframe 元素中的 srcdoc 属性中使用链接时,链接相对于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45124865/