zl程序教程

您现在的位置是:首页 >  后端

当前栏目

解决用jqueryload加载页面到div时,不执行页面js的问题

JS执行 问题 解决 页面 加载 div jqueryload
2023-06-13 09:15:18 时间

jquery代码:

复制代码代码如下:

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

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

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

复制代码代码如下:

<divid="test">
   <iframename="testLoad"style="width:100%"></iframe>
</div>

js事件:
复制代码代码如下:
functionloadPage(){
   window.open("${contextPath}/notepad/toCreate.do","testLoad","");//testLoad为iframe的name属性
}

按钮:
复制代码代码如下:
<inputtype="button"value="加载"onclick="loadPage()"/>

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