简体   繁体   English

在iframe中插入JavaScript文件

[英]Insert javascript file inside iframe

I'm trying to do the following: 我正在尝试执行以下操作:

    <iframe width="300">
      <script type="text/javascript" src="file.js" charset="utf-8"></script>
    </iframe>

But this constructions seems not working. 但是这种构造似乎行不通。 What is the legitimate way to insert javascript file inside iframe using HTML and not calling javascript functions? 使用HTML在iframe中插入javascript文件而不调用javascript函数的合法方法是什么? Is it even possible? 它甚至可能吗?

You cannot add any content directly into an <iframe> tag. 您不能将任何内容直接添加到<iframe>标记中。 Even using JavaScript, you can add content only if the page in the iframe is from the same domain as the parent page. 即使使用JavaScript,也只能在iframe中的页面与父页面位于同一域中时添加内容。

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

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