javascript - 如何使用 iframe 加载 html?

标签 javascript jquery html css iframe

我有:

index.html

test.html

我可以用 jquery load(); 加载我的 test.htmlindex.html

中的函数

但是我的 index.html 样式被破坏了,这就是为什么我想将我的 test.html 作为 iframe 加载到 index.html 中..

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>

<h1>index.html</h1>

<div class="item">
load test.html here with iframe
</div>

<div class="test">
I'm a test div and I want to be in index.html in `item` class
</div>

最佳答案

将 html 文件加载到 iframe 中

<html>
<body>

  <iframe src="test.html">
    <p>Your browser does not support iframes.</p>
  </iframe>

</body>
</html>

关于javascript - 如何使用 iframe 加载 html?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44436836/

相关文章:

javascript - Material Design 组件文本字段的标签不会 float 到左上角

javascript - HTML 按钮点击顺序还是并行?

javascript - 单击时隐藏按钮几秒钟

javascript - 如何触发我的 jquery 表单提交

javascript - Javascript 中的毕达哥拉斯三元组公式 - Project Euler Prob 9

javascript - 将 jquery 插件转换为指令 Angular

javascript - 当通过元素的 id 与元素一起使用时,jQuery .load() 是否会加载整个页面?

jQuery val 返回空字符串

javascript - Reactjs 不断抛出错误 "TypeError: this.goActive is not a function"

javascript - 在另一个js文件中使用javascript函数