Giliweed Giliweed - 5 months ago 17
Javascript Question

How do I load an HTML page in a <div> using JavaScript?

I want home.html to load in

<div id="content">
.

<div id="topBar"> <a href ="#" onclick="load_home()"> HOME </a> </div>
<div id ="content"> </div>
<script>
function load_home(){
document.getElementById("content").innerHTML='<object type="type/html" data="home.html" ></object>';
}
</script>


This works fine when I use Firefox. When I use Google Chrome, it asks for plug-in. How do I get it working in Google Chrome?

Answer

I finally found the answer of my problem. The solution is

 function load_home(){
document.getElementById("content").innerHTML='<object type="text/html" data="home.html" ></object>';
}

Not

function load_home(){
document.getElementById("content").innerHTML='<object type="type/html" data="home.html" ></object>';
}

I made a silly mistake while typing. when I corrected type="text/html" , it works fine in google chrome. :)

Comments