Home > Web Front-end > JS Tutorial > JavaScript problem analysis on refreshing the parent page after the open.window subpage is executed_javascript skills

JavaScript problem analysis on refreshing the parent page after the open.window subpage is executed_javascript skills

WBOY
Release: 2016-05-16 16:01:57
Original
1041 people have browsed it

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="添加" />
Copy after login

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;
}
Copy after login

The addInfo.jsp page has the following code:

<form name="form" action="AddSocket" method="get">
<input id="onSub" type="button" onclick="formSubmit();" value="确定">
</form>
Copy after login
function formSubmit(){
this.form.submit();
//提交action到AddSocket类
window.opener.callback();
//上述执行完成后,调用打开页面的callback方法,
//此处是调用主页面的callback方法
window.close();//当前页面关闭
}
Copy after login

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类,如果要传参数,用&#63;即可
window.location.href = DeleteSocket
Copy after login

DeleteSocket class page:

Copy code The code is as follows:
//After performing a series of operations, you can directly write JavaScript code
//After writing this sentence, you can jump directly to the main page and refresh the main page

out.print("");

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template