无法从其他文件加载html

时间:2014-05-02 10:53:25

标签: javascript jquery ajax node.js sails.js

我有以下代码:

<script>
   var load = function load_home(){
    document.getElementById("content").innerHTML='<object type="type/html" data="/linker/templates/button.html" ></object>';
   }
</script>
<div id="content"></div>

但是它没有加载任何东西,控制台也没有显示任何错误。 这是在sails.js应用程序

1 个答案:

答案 0 :(得分:1)

你没有调用加载函数,在窗口加载时调用它,

<script>
   var load = function load_home(){
    document.getElementById("content").innerHTML='<object type="type/html" data="/linker/templates/button.html" ></object>';
   }
   window.onload=function(){
      load();
  }
</script>
<div id="content"></div>