javascript - 如何将 HTML 页面加载到 JSP 中的 DIV 中(不加载任何内容)

标签 javascript jquery html jsp

有人可以给我建议如何让它发挥作用吗?

<html>
<head>
    <script src="../js/jquery-1.9.1.js"></script>
</head>
<body>
    <div id="divpage"></div>
    <script>
      $("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");
      alert( "Load was performed." );
    </script>
</body>
</html>

最佳答案

浏览器必须加载完整的 DOM,然后才能使用 javascript 操作它, 在 Jquery 中使用 .ready()

$(document).ready(function()
{
    $("#divpage").load("http://localhost:3000/annotation/testuser/demo.html");

});

关于javascript - 如何将 HTML 页面加载到 JSP 中的 DIV 中(不加载任何内容),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30089411/

相关文章:

javascript - 将 JavaScript 检测与 MVC4 显示模式集成的最佳方式是什么?

javascript - Dropzone.js 事件未触发

javascript - 在 div 中裁剪和居中任意大小的图像

javascript - 一个很好的 JavaScript 来从/到数组添加/删除项目?

javascript - 如何防止iframe影响浏览器历史记录

javascript - jquery $.ajax 强制 POST

jquery - 如果 this = 第一个 <li> 类为 'xyz' 则运行函数

javascript - 如何在 jquery 中循环第二个元素?

javascript - 选择列表为空时水平缩小

javascript - 表达式前面有加号有什么用