如何在< div>中加载HTML页面使用JavaScript? [英] How do I load an HTML page in a <div> using JavaScript?
本文介绍了如何在< div>中加载HTML页面使用JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望home.html载入< div id =content>
。
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>
当我使用Firefox时,此工作正常。当我使用谷歌浏览器时,它会要求插件。我怎么才能让它在谷歌浏览器中工作?
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?
推荐答案
我终于找到了我的问题的答案。解决方案是:
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>';
}
这篇关于如何在< div>中加载HTML页面使用JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文