How can I insert an external html file to my file?
For instance:
<div id="header">
Here show the external HTML code in the file, for example: name.html
</div>
Thank you very much!
This question is related to
html
You can use jquery load for that.
<script type="text/javascript">
$(document).ready(function(e) {
$('#header').load('name.html',function(){alert('loaded')});
});
</script>
Don't forget to include jquery library befor above code.
The iframe element.
<iframe src="name.html"></iframe>
But content that you way to have appear on multiple pages is better handled using templates.
Another way is to use the object tag. This works on Chrome, IE, Firefox, Safari and Opera.
<object data="html/stuff_to_include.html">
Your browser doesn’t support the object tag.
</object>
more info at http://www.w3schools.com/tags/tag_object.asp
You're looking for the <iframe>
tag, or, better yet, a server-side templating language.
Source: Stackoverflow.com