Home >Web Front-end >JS Tutorial >JavaScript problem analysis on refreshing the parent page after the open.window subpage is executed_javascript skills
This article analyzes the JavaScript method of refreshing the parent page after the open.window subpage is executed. Share it with everyone for your reference. The specific analysis is as follows:
Main page:
<input id="btnAdd" type="button" onclick="openWin();" value="添加" />
There is the following code in js:
function openWin() { window.open('addInfo.jsp', '_blank', 'width=300,height=400,top=200,left=400'); } //定义callback方法,用于回调 function callback() { refreshWin(); } //刷新当前页面 function refreshWin() { //调用刷新页面的方法,此处RefreshSocket为刷新页面对应的方法 //也就是说,如果页面有个刷新按钮, //则点击按钮提交的类名就是此处的类名 var url = 'RefreshSocket'; window.location.href = url; }
The addInfo.jsp page has the following code:
<form name="form" action="AddSocket" method="get"> <input id="onSub" type="button" onclick="formSubmit();" value="确定"> </form>
function formSubmit(){ this.form.submit(); //提交action到AddSocket类 window.opener.callback(); //上述执行完成后,调用打开页面的callback方法, //此处是调用主页面的callback方法 window.close();//当前页面关闭 }
In addition, if it is an operation like deletion, jump directly from a jsp to a class. After performing a series of operations in the class, if you want to refresh the current page, you can write jump statements directly in the class. That’s it, as shown below:
Main page mainPage.jsp:
//删除操作关联后台的DeleteSocket类,如果要传参数,用?即可 window.location.href = DeleteSocket
DeleteSocket class page:
out.print("7c6ecc2a75ade4ffa1f50134f6be3b0elocation.href='mainPage.jsp'2cacc6d41bbb37262a98f745aa00fbf0");
I hope this article will be helpful to everyone’s JavaScript programming design.