endless loop reloading parent of iframe?! Why? :(

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

endless loop reloading parent of iframe?! Why? :(

Post by robster »

Hi there, I'm having some trouble with endless loops when I try and exit my iframe and relod its parent file... Here is the quite nested list of files.


Code: Select all

POS.php
|
|
--includes MAIN_POS.PHP
	|	
	|
	--includes POS_IFRAME_LIST.PHP
		|
		|
		--includes POS_IFRAME_CONTENTS.PHP
			|
			|
			--includes POS_TRANS_EDIT.PHP
What happens is the pos_iframe_list.php file includes the pos_iframe_contents.php file in an iframe.
The pos_iframe_contents.php file has an edit button, that when pressed, calls via form data, pos_trans_edit.php. After pos_trans_edit.php does its thing to the database it wants to refresh the complete pos.php file so other data on that page can now be updated with the new changed data in the database.

When I try and do with javascript this, I either get:

A)looping refresh of the iframe -- parent.document.location.reload();
B)looping refresh of the whole page -- window.parent.location.reload();
C)no refresh -- lots of other javascript tried here



Can anyone give some suggestions? I'd really appreciate it.


Rob
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

I'm still having trouble here. It's something that's becoming the thorn in my side :)

In logical sense, if I tell the last include to reload its parent, then that should be fine, as the parent is the CONTENT of the iframe itself. What I need I guess is to reload the root parent!

Does anyone know how I can do that that (reload POS.php from POS_TRANS_EDIT.php)?

Cheers,

Rob
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

you might try something like:

Code: Select all

top.location.reload();
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

Thanks for that, it still made it loop though. I finally got it with this:

Code: Select all

echo <<<JS
<script language="JavaScript">
parent.history.go(-1);
parent.window.reload();
</script>  
JS;
It goes back in history, but that's not a problem as it reloads the page. That means any old data that was on that page gets refreshed from the database on the reload.

PHEW! that took way too long LOL :)

rob

(thanks again)
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

no, I take it back :)

Actually, it is going back in history, but not reloading the parent... sigh...
User avatar
robster
Forum Contributor
Posts: 360
Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia

Post by robster »

LOL, talk about trial and error!!!

:)

Code: Select all

echo <<<JS
<script language="JavaScript">
top.location = "pos.php";
</script>  
JS;

works.. done... dusted... over n out :)
Post Reply