0

sorry if this is a repeat question!

I have the following Javascript which works fine in Firefox and produces a pop up window. In IE 9 however it does nothing at all and in Chrome it works like a link and changes the current page!

Any advice appreciated!

window.open(page,name,'width='+width+', height='+height+',location=yes,menubar=no,resizable=no,toolbar=no,scrollbars=yes');

Thanks in advance.

Rhys
  • 1,439
  • 1
  • 11
  • 23
Shaun Hogg
  • 177
  • 2
  • 14

3 Answers3

2

This is a working example

JS

function openWindow()
{
    var width=668;
    var height=548;
    var page="http://google.com";
    window.open(page, "awindow", "width="+width+",height="+height+",location=yes,scrollbars=yes, resizable=yes");
}

HTML

<a href="javascript:openWindow()">Open</a>​

DEMO.

The Alpha
  • 143,660
  • 29
  • 287
  • 307
1

Did you create the variables correctly?

This code is working for me:

var page = 'page.php';
var name = 'pagename';
var width = 200;
var height = 100;
window.open(page,name,'width='+width+', height='+height+',location=yes,menubar=no,resizable=no,toolbar=no,scrollbars=yes');

EDIT

In my webapp I use the following function for opening windows. It should work in all browsers.

function wopen(url, name, w, h, scrollb) {
    scrollb = typeof(scrollb) != 'undefined' ? scrollb : 'no';
    w += 32;
    h += 96;
    wleft = (screen.width - w) / 2;
    wtop = (screen.height - h) / 2;
    var win = window.open(url, name,
    'width=' + w + ', height=' + h + ', ' + 'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=' + scrollb + ', resizable=yes');
    // Just in case width and height are ignored
    win.resizeTo(w, h);
    // Just in case left and top are ignored
    win.moveTo(wleft, wtop);
    win.focus();
}
Bram Verstraten
  • 1,414
  • 11
  • 24
0

Where are you making the call to window.open? IE9 will block calls if they're made during page load as part of its popup blocker. Chrome does something similar, but redirects new windows to the main tab (thus, putting the user in control). As for Firefox... check your FF popup blocker settings.

Dai
  • 141,631
  • 28
  • 261
  • 374
  • It is in a orders system when the user clicks update status they are given (in firefox anyway!) a pop up window with a drop down multi select (i.e. shipped, completed etc) and a submit button. Thus the pop up is triggered by the user – Shaun Hogg Jul 25 '12 at 13:28