如何将外部html文件插入到我的文件中?
例如:
<div id="header">
Here show the external HTML code in the file, for example: name.html
</div>
Run Code Online (Sandbox Code Playgroud)
非常感谢你!
小智 42
另一种方法是使用object标签.这适用于Chrome,IE,Firefox,Safari和Opera.
<object data="html/stuff_to_include.html">
Your browser doesn’t support the object tag.
</object>
Run Code Online (Sandbox Code Playgroud)
更多信息, 请访问http://www.w3schools.com/tags/tag_object.asp
Raj*_*iya 11
你可以使用jquery加载.
<script type="text/javascript">
$(document).ready(function(e) {
$('#header').load('name.html',function(){alert('loaded')});
});
</script>
Run Code Online (Sandbox Code Playgroud)
不要忘记在上面的代码中包含jquery库.
| 归档时间: |
|
| 查看次数: |
100724 次 |
| 最近记录: |