zoukankan      html  css  js  c++  java
  • 解决用jquery load加载页面到div时,不执行页面的js

    jquery代码:

    $(function(){
      $("#test").load("${contextPath}/notepad/toCreate.do");

    加载 ${contextPath}/notepad/toCreate.do 页面到id为test的div中,加载完成之后,create页面中的js不会执行

    这种方式没办法实现,换个思路:

    <div id="test">
    <iframe name="testLoad" style="100%"></iframe>
    </div>

    js事件:

    function loadPage(){
    window.open("${contextPath}/notepad/toCreate.do",'testLoad','');// testLoad为iframe的name属性
    }

    按钮:

    <input type="button" value="加载" onclick="loadPage()" />

    点击按钮时,加载页面到iframe中,里面的js是可以使用的,感觉不太好,就像是刷新页面了一样......


     

  • 相关阅读:
    String
    Map和Set
    js的栈与堆
    js的私有属性
    随便谈一谈原型
    前端页面优化提速
    nth-child和nth-of-type
    重复输出字符串
    闭包
    mongodb内嵌文档的查询
  • 原文地址:https://www.cnblogs.com/zhouyalei/p/2290315.html
Copyright © 2011-2022 走看看