1

So I've got this code to open up a gallery window, passing which category and which number/item from that category to display. It's working fine in Firefox and Chrome, but IE 9 keeps breaking on the window.open line, what am I doing wrong?

function newWindow(cat,n) {
  var newWindow = "display.php?cat=" + cat + "&n=" + n;
  var windowOpen = window.open (newWindow, 'Portfolio Display', 'height=622,width=960,toolbar=0,menubar=0,scrollbars=0,resizable=0,location=0,directories=0,status=0');
  windowOpen.focus();
};

The newWindow variable was so that I didn't have to have a long string of quotes in there (just making sure that wasn't the error.

MaVRoSCy
  • 17,747
  • 15
  • 82
  • 125
MDWar
  • 103
  • 13

2 Answers2

4

Don't use a space in the second parameter. I swear I've had trouble with this in the past, and I just stick to alphanumeric characters (UPDATE: I forgot about "_" as well) for the window "name" (second parameter). If this doesn't fix the problem in IE, although it has for me (I forget what versions I tested on), you can look at:

ie8 var w= window.open() - "Message: Invalid argument."

Community
  • 1
  • 1
Ian
  • 50,146
  • 13
  • 101
  • 111
  • Simply out of curiosity, is it possible to use a   in there instead of a standard space (which doesn't work) or a underscore? – MDWar Oct 12 '12 at 21:34
  • @MDWar I highly doubt it. I'm not sure you understand exactly what the second parameter does. It doesn't set the `` of the document, it just provides a way for Javascript to uniquely identify it. If you try to call `window.open` twice with the same second parameter (using a custom value, not like "_blank"), it won't open two new windows. It will load the window with the URL the first time, then just reload it the second time. – Ian Oct 12 '12 at 23:39
  • I understand that, I wanted to make sure that as you clicked on different items in the gallery that it wouldn't go and open up a bunch of different windows, but would instead open in the same window. That being said, I just ended up dropping in my lightbox script because Chrome was opening the window the right size, FF was opening it about 70px smaller on the width, and IE was opening it an extra 30px. Thank you for your help though. – MDWar Nov 02 '12 at 17:25
  • @MDWar Right, I just wanted to make sure you understood that ` ` has no significance compared to a normal space...since you seemed to "need" ` ` – Ian Nov 02 '12 at 18:25
  • Yeah, I had some idea in my head that that name would be visible, but it wasn't, which was the entire point of displaying the name. – MDWar Nov 05 '12 at 04:59
0

Oops, it turns out the problem was where I had 'Portfolio Display' as the second bit in window.open. Removed that and left it as

...newWindow, '', 'height...

and it works like a jiffy.

MDWar
  • 103
  • 13