Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Refresh Upon Popup Close
Old 11-02-2007, 03:14 PM Refresh Upon Popup Close
BlackWater's Avatar
Experienced Talker

Posts: 31
Trades: 0
I'm scripting a website that when the user wants to edit part of the site a popup is opened containing a form to edit the content. Upon clicking submit it runs some PHP script and then tells the user that the changes have been made. When the user clicks `ok' I want the popup to close and the main page to refresh so the user can view his or her results.

I understand that PHP is not client side and that it cannot do this. Is there anyway I can accomplish this using PHP or some other script?

Thanks
__________________
Code:
if( $hungry ) { eat(); } 
    else { sleep(); }
BlackWater is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 11-02-2007, 06:54 PM Re: Refresh Upon Popup Close
Extreme Talker

Posts: 238
Location: United States
Trades: 0
You are right that PHP can't do this, so the PHP forum is sort of the wrong place for this. Anyway, you can accomplish this with JavaScript. Just call the following JavaScript snippet with the user presses OK:

Code:
window.opener.location.href=window.opener.location.href; // refresh the main page
window.opener.focus(); // focus on the main page
window.close(); // close the popup page
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
frost is offline
Reply With Quote
View Public Profile
 
Old 11-03-2007, 01:55 AM Re: Refresh Upon Popup Close
BlackWater's Avatar
Experienced Talker

Posts: 31
Trades: 0
Yeah, I realized the basis of my question was geared more towards Javascript after I had clicked create new post.

So to make that work I'd shove that all in a "onClick" attr. in a input tag?
__________________
Code:
if( $hungry ) { eat(); } 
    else { sleep(); }
BlackWater is offline
Reply With Quote
View Public Profile
 
Old 11-03-2007, 03:11 AM Re: Refresh Upon Popup Close
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,938
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
Trades: 0
Or write a function for it and call the function via onclick. That's always the better way to do it since it separates HTML from Javascript (trust me, it'll be much easier that way to read.)
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
(my blog)


Please login or register to view this content. Registration is FREE
(with proof)
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 11-05-2007, 10:52 PM Re: Refresh Upon Popup Close
BlackWater's Avatar
Experienced Talker

Posts: 31
Trades: 0
My question is more geared towards the syntax of the coding. How would I do that?
__________________
Code:
if( $hungry ) { eat(); } 
    else { sleep(); }
BlackWater is offline
Reply With Quote
View Public Profile
 
Old 11-05-2007, 11:36 PM Re: Refresh Upon Popup Close
Extreme Talker

Posts: 238
Location: United States
Trades: 0
To put the code in a function, just do something like this:
Code:
function closePopup(){
   window.opener.location.href = window.opener.location.href;
   window.opener.focus();
   window.close();
}
Add that JavaScript to your popup page, either in the <head> portion in between <script></script> tags, or in a external .js file which would be referenced in the <head> portion of your document by <script type="text/javascript" src="myjavascript.js"></script>.

Then to call that code, use either an onclick attribute as you mentioned or an anchor element's href attribute.

opt 1)
HTML Code:
<a onclick="closePopup();" href="#">Close Window</a> <!-- You don't have to use the anchor element; this is just an example. -->
opt 2)
HTML Code:
<a href="javascript:closePopup();">Close Window</a>
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
frost is offline
Reply With Quote
View Public Profile
 
Old 11-06-2007, 03:03 PM Re: Refresh Upon Popup Close
rohan_india's Avatar
Novice Talker

Posts: 9
Name: Rohan Shenoy
Location: Thane-Vashi,Mumbai,India
Trades: 0
Creating a pop-up would make the task more complicated in my thinking.
Instead, when a user clicks on EDIT CONTENT, let a DIV appear(display:inline) at bottom of page with all editing options.

When the user clicks 'Finished editing' or 'Update content', the DIV shall disappear(display:none) and a setTimeout("url here",2000) function will be activated.


By using this delay of 2000milliseconds, we are making sure that the edited content is posted to the server and onreloading the page, the user gets updated content.
rohan_india is offline
Reply With Quote
View Public Profile Visit rohan_india's homepage!
 
Old 11-08-2007, 01:29 PM Re: Refresh Upon Popup Close
BlackWater's Avatar
Experienced Talker

Posts: 31
Trades: 0
How many excess pages would that honestly yield over doing it with pop-ups and javascripting?
__________________
Code:
if( $hungry ) { eat(); } 
    else { sleep(); }
BlackWater is offline
Reply With Quote
View Public Profile
 
Old 08-15-2008, 10:25 AM Re: Refresh Upon Popup Close
Junior Talker

Posts: 1
Name: Enisa
Trades: 0
But this doesn't refresh whole page, if it is contained with few frames.
In my case, from master page (index.php) that is cntained with 3 frames, from one frame it is opened a popup window. When this popup window closes, it refresh only that frame, not the whole page.
how can i make him reload whole page index.php?
thx
enisonica is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Refresh Upon Popup Close
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.31899 seconds with 12 queries