PDA

View Full Version : [javascript] IE window.open problem



Maniaci
November 28th, 2004, 04:23 PM
Alright, IE is really makin' me mad here. This script works perfectly in Mozilla Firefox, but does not work at all in IE.

Here is the code on the button:


<input type=button value="Launch Image" onClick="openWin('http://www.mysite.com/img_database/window.php?img=<? echo $_GET['img']?>');">


Here is the openWin function:


function openWin(url){
window.open(url,'Triplebros - Image Download','toolbar=0,menubar=0,status=0,resize=0,d ependent=1,location=0,scrollbars=0,height=650,widt h=800,left=40,top=40')
}


The openWin function was not always its own function, it also didn't work when i had the window.open(...) on the button with an onClick.

Any help on this would be fantastic, thanks.

ironikart
November 28th, 2004, 10:09 PM
the window.open() method returns an instance of a sub window... maybe try storing the reference to get it to work properly:



var newWin = null
function openWin(url){

if (!newWin || newWin.closed) {
newWin = window.open(url,'Triplebros - Image Download','toolbar=0,menubar=0,status=0,resize=0,d ependent=1,location=0,scrollbars=0,height=650,widt h=800,left=40,top=40')
} else {
newWin.focus()
}
}

lostinbeta
November 28th, 2004, 11:58 PM
'Triplebros - Image Download' seems to be your problem. You can't have spaces in the window name argument. I'm not sure about a '-' either (never used it in a window name), usually it's good to stick with a-z, 0-9, and underscores in place of spaces.

[m]
November 29th, 2004, 01:11 PM
A "window name" is a unique identifier used in javascript. This is in no way related to the text in the title bar!

Maniaci
November 30th, 2004, 06:51 PM
Lostinbeta you saved my life... thanks. It was the fact that I had spaces and a "-" in my title that was giving me the error.