open popup>close>refresh main

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
cryogenic
Forum Newbie
Posts: 3
Joined: Thu Jul 27, 2006 8:08 am

open popup>close>refresh main

Post by cryogenic »

there are 2 pages :
main.php
popup.php

--------------------------------

main.php :
has a link that open a new window (popup.php)

popup.php :
has a form. once the button is clicked, it will update the database, then this new window will close automatically.

when the new window closed, main.php will refresh automatically.

how to make these things possible? FYI, im using macromedia dreamweaver. sorry if my english is bad.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Put this is you <head> tag

Code: Select all

<script language="JavaScript">
<!--
function refreshParent() {
  window.opener.location.href = window.opener.location.href;

  if (window.opener.progressWindow)		
  {
    window.opener.progressWindow.close()
  }
  window.close();
}
//-->
</script>
Then, after you have done your DB update, just call

Code: Select all

<script language="JavaScript">refreshParent();</script>
And please try to post in the correct forum!
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:1. Select the correct board for your query. Take some time to read the guidelines in the sticky topic.
cryogenic
Forum Newbie
Posts: 3
Joined: Thu Jul 27, 2006 8:08 am

Post by cryogenic »

where should i put those codes. main.php or popup.php. i know nothing bout javascript.

* its in the rite place now. thanks mod. sorry anyway.. :D
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

put it in popup.php
cryogenic
Forum Newbie
Posts: 3
Joined: Thu Jul 27, 2006 8:08 am

Post by cryogenic »

solved!!!!

when db update done, just call the refreshParent

Code: Select all

if ($updateSQL) {
  echo "<body onload='refreshParent()'>"; }
thanks!!!!!!
Post Reply