How to use Javascript window name in PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
BlueHippo
Forum Newbie
Posts: 9
Joined: Tue Aug 02, 2005 8:45 pm

How to use Javascript window name in PHP?

Post 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);
}
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

php doesn't interact with the browser directly, especially in "real-time" so yeah.. you need Javascript.
BlueHippo
Forum Newbie
Posts: 9
Joined: Tue Aug 02, 2005 8:45 pm

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

Perhaps this will help?

Post by AnarKy »

Perhaps this will help?

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

You should browse around as well. :arrow:
BlueHippo
Forum Newbie
Posts: 9
Joined: Tue Aug 02, 2005 8:45 pm

Post 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
Post Reply