解决用jquery load加载页面到div时,不执行页面js的问题
解决用jquery load加载页面到div时,不执行页面js的问题
发布时间:2016-12-30 来源:查字典编辑
摘要:jquery代码:复制代码代码如下:$(function(){$("#test").load("${contextPath}/notepad...

jquery代码:

复制代码 代码如下:

$(function(){

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

}

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

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

复制代码 代码如下:

<div id="test">

<iframe name="testLoad"></iframe>

</div>

js事件:

复制代码 代码如下:

function loadPage(){

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

}

按钮:

复制代码 代码如下:

<input type="button" value="加载" />

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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类