最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to reload the already existing page after closing popup window - Stack Overflow

programmeradmin2浏览0评论

i am using javascript, php, mysql.
I have a button on 'index.php'. A new window will open on click of this button(not new tab)
The code is like this.

function getUtilities(sid,sfname,smobnum,subdid)
{   
   var url='';
   url="update.php?sid="+sid+"&sfname="+sfname+"&smobnum="+smobnum+"&subdid="+subdid;
   popupNote(url);  
}


function popup(url)
{
 var width  = 500;
 var height = 200;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}

So i will have my popup opened. i am performing some update operation.. and i'l close it. After closing the popup i want to refresh my 'index.php'. But i am unable to do that.

i am using javascript, php, mysql.
I have a button on 'index.php'. A new window will open on click of this button(not new tab)
The code is like this.

function getUtilities(sid,sfname,smobnum,subdid)
{   
   var url='';
   url="update.php?sid="+sid+"&sfname="+sfname+"&smobnum="+smobnum+"&subdid="+subdid;
   popupNote(url);  
}


function popup(url)
{
 var width  = 500;
 var height = 200;
 var left   = (screen.width  - width)/2;
 var top    = (screen.height - height)/2;
 var params = 'width='+width+', height='+height;
 params += ', top='+top+', left='+left;
 params += ', directories=no';
 params += ', location=no';
 params += ', menubar=no';
 params += ', resizable=no';
 params += ', scrollbars=yes';
 params += ', status=no';
 params += ', toolbar=no';
 newwin=window.open(url,'windowname5', params);
 if (window.focus) {newwin.focus()}
 return false;
}

So i will have my popup opened. i am performing some update operation.. and i'l close it. After closing the popup i want to refresh my 'index.php'. But i am unable to do that.

Share asked Nov 3, 2014 at 7:40 MatarishvanMatarishvan 2,4323 gold badges42 silver badges71 bronze badges 2
  • you can use location.reload(). – Sougata Bose Commented Nov 3, 2014 at 7:42
  • where do i use? index.php? or update.php? i need to reload after performing some action in update.php(new window) – Matarishvan Commented Nov 3, 2014 at 7:44
Add a ment  | 

1 Answer 1

Reset to default 7

You will want to run the following JS on the popup window when you are ready to reload the parent page and close the popup.

<script>
  window.opener.location.reload();
  window.close();
</script>
发布评论

评论列表(0)

  1. 暂无评论