Change window location then iframe src when press button

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
soder
New php-forum User
New php-forum User
Posts: 15
Joined: Fri Mar 16, 2012 7:38 pm

Fri Apr 06, 2012 1:26 pm

Heya, as the title says I want to refresh the browser and go to "www.mydomain.com", then change the iframe src to "www.mydomain.com/php/account.php?action ... ogout=true"

I currently got this code

Code: Select all

echo "<script type='text/javascript'>";
echo "parent.window.location='http://mydomain/';"; //main window
echo "window.location='http://mydomain.com/php/account.php?action=login&logout=true';"; //iframe
echo "</script>";
I know parent.window.location work, so does window.location for the iframe, but it only does one of the actions, the first one.

The reason to use both of them is when you login you get extra buttons to the menu, and when you logout i need it to refresh the website to remove the buttons, and still redirect the iframe to the login form with a cute good-bye message.

Any suggestions?

EDIT: I dont want to use any $_GET on the main window(mydomain.com?logout=true) then use javascript to redirect the iframe.

Kind regards,
Soder.

User avatar
gandahar
New php-forum User
New php-forum User
Posts: 112
Joined: Tue Mar 15, 2011 4:05 am

Fri Apr 27, 2012 5:23 pm

i dont understand really where is the iframe and from where you want to redirect, but take a look :

Code: Select all

parent.document.location.href=URL;
document.location.href=iFrameURL;
but, hey, if you first load a page to parent, iframe will disappear ;)

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 3 guests