Main page:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Including external content with ajax + object</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<!--[if !IE]><!-->
<script type="text/javascript">
document.write('<object type="text/html" name="object_name" width="0" height="0" data="external.html"><\/object>');
</script>
<!--<![endif]-->
<!--[if IE]>
<script type="text/javascript">
document.write('<iframe name="object_name" width="0" height="0" src="external.html"><\/iframe>');
</script>
<![endif]-->
<script type="text/javascript">
onload=function(){
document.getElementById('main_page_id').innerHTML = window.frames['object_name'].document.getElementById('some_external_div').innerHTML}
</script>
</head>
<body>
<div id="main_page_id"></div>
And this is the content of the main page.
</body>
</html>
External page (external.html):
Code:
<div id="some_external_div">
This is some part of of an external file<br>
</div>
This is the rest of the external file.
Arie Molendijk.
Bookmarks