Solve the problem of not executing page js when loading a page into a div with jquery load
- 2020-03-30 02:07:28
- OfStack
Jquery code:
$(function(){
$("#test").load("${contextPath}/notepad/toCreate.do");
}
Load the ${contextPath}/notepad/ tocreat.do page into the div with id of test. After loading, the js in the create page will not execute
There's no way to do this. Think of it differently:
<div id="test">
<iframe name="testLoad" style="width:100%"></iframe>
</div>
Js:
function loadPage(){
window.open("${contextPath}/notepad/toCreate.do",'testLoad','');//TestLoad is the name property of the iframe
}
Button:
<input type="button" value=" loading " onclick="loadPage()" />
When you click the button, load the page into the iframe, the js inside is available, it doesn't feel good, just like refreshing the page...