Page 1 of 1

How to use Javascript window name in PHP?

Posted: Wed Aug 03, 2005 10:38 pm
by BlueHippo
Hi Everyone,

How can i use a Javascript window popup name in the PHP??

I have windowA, windowB and windowC in my application. When i close windowA, i want windowB to refresh and windowC to be close too. can i do that with PHP or need to adding in the javascript??

Anyone got any IDEAS with this?? Thanks

Here is my code:

This is the open popup window script that i use in the window.js
(I use dynamic window name that pass in from windowA, different window have different name)

function child_window(mylink, windowname, winfeatures)
{
var mywin, href;

href = mylink.href;
mywin = window.open(mylink, windowname, winfeatures);
}

Posted: Wed Aug 03, 2005 11:01 pm
by feyd
php doesn't interact with the browser directly, especially in "real-time" so yeah.. you need Javascript.

Posted: Thu Aug 04, 2005 12:38 am
by BlueHippo
Hi feyd,

Thanks for reply :) u are right, i need to use the Javascript to do it.....

Can anyone give me some example???

Thanks

Posted: Thu Aug 04, 2005 1:48 am
by Burrito
I assume you're talking about pop-up windows?

you can do it all with js, however almost every browser nowadays will not work with the onUnLoad event.

you'd therefore be "requiring" your users to click a link to close your browser a window and manipulate stuff on browser b and c.

you just need to give each window a variable name and then you can do stuff with them as follows:

Code: Select all

bob.window.close();
// or
bill.document.MyForm.somefield.value = "blah";
// etc

Perhaps this will help?

Posted: Thu Aug 04, 2005 1:51 am
by AnarKy
Perhaps this will help?

http://www.irt.org/script/1476.htm

You should browse around as well. :arrow:

Posted: Thu Aug 04, 2005 2:15 am
by BlueHippo
Hi Burrito and AnarKy,

Thanks for the advice :P

So, thats mean i need to declare a variable for each popup window, right?
Like:
windowA = window.open('url.php,'windowname',features);
windowB = window.open('address.php,'windowname',features);

and we call the windowA or windowB every time we want to perform actions to that particular window, right??

Then, how about if my window is a dynamic window which passing the 'windowname' throught php page??

For example:
In php file:

$_session['user_ID']=$ID;
$_session['category']=$choice;

print('<a href="hello.php" onClick="return special_window(this,\''.$ID.$choice.'\',\'toolbar=No,menubar=No,scrollbars=Yes\')">click here</a>');

//so the $ID and the $choice will be different when the user click on different category(each category will open a popup window).

In window.js file
function open_window(url,name,feature)
{ windowA = window.open(url,name,feature);

so, the 'windowname' will be different each time a popup window created......

For this case, can i just declare the window open like that...??

function open_window(url,name,feature)
{ name = window.open(url,name,feature);

but when i put this script in, i close window but nothing happen.... 8O

Anyone can help me?? thanks