Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a window name to a popup

Status
Not open for further replies.

gameon

Programmer
Feb 23, 2001
325
GB
Hi, I am using the following script ot popup a window:

<script>
// JavaScript Document
function PopDetails(WinName,theWidth,theHeight,theURL){
xpos = Math.round((screen.width/2)-(theWidth/2)-13);
ypos = Math.round((screen.height/2)-(theHeight/2));
WinName = window.open(theURL,'WinName', 'width='+theWidth+',height='+theHeight+'location=no,menubar=no,personalbar=no,resizable=no,screenX=' + xpos + ',screenY=' + ypos + ',left=' + xpos + ',top=' + ypos + ',locationbar=no,scrollbars=no,directories=no,statusbar=no,toolbar=no');
WinName.focus();
}
</script>

In the script, the dimentions etc are passed to the function. It works very nicely.

This is ideal for opening content into one window. But, I need it to work with lots. Therefore I need to pass the name of the window - which I'm doing, but the attribute is not be evaluated. Its just calling every window the same thing.

I have trioed modifying to:

[WinName] = window.open(...

and

eval(WinName) = window.open(...

But no joy. Please enlighten...

M@)
 
how about an array of windows....

WinName[passedVal] = window.open(...


I've never tried it, but it should work...


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
Here is what i noticed opening more then 1 popup.
If you place same - window.open(theURL,'WinName', ...) - name it will open in the same popup window.
You need to give them random names or just test with null value. It should work.

window.open(theURL,null, ...)

________
George, M
 
Hi, 'winname' is supposed to be a variable holding the name that the window will be.

This way, if I want things to open in the same window - I use the same name as another that may exist - or if I want it in a different window I would pass it a different name.

mwolf00, using WinName[passedVal] doesn;t seam to work.

I need to be able to dynamically name a WinName to be what ever name is passed to it...

M@?
 
Ok then use the variable without '' just
window.open(theURL,WinName, ...)
WinName it's a variable, but inside 'WinName' it's just a simple string.

________
George, M
 
I'm a moron. (drank too much last night) All I had to do was take the '' out...

Cheers,

M@
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top