简体   繁体   中英

How To Create a Popup Window from Internet Explorer 9

I'm using the following to attempt to create a popup in IE 9

function popUp(url) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(url,'" + id + "','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=520,left = 400,top = 200');");
  return false;
}

This works fine in Chrome, Firefox and Safari - but IE 9 refuses to open a popup - instead opening the url in a new tab. I've disabled the popup blocker in IE9 - but the function above still opens the url in a new tab and not in a popup.

Any suggestions on how to get IE9 to 'popup'?

This code seems to work in IE9 (just checked - opens a new window, not a tab):

function popUp(url) {
  day = new Date();
  id = day.getTime();
  eval("page" + id + " = window.open(url,'" + id + "','_blank','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=600,height=520,left = 400,top = 200');");
  return false;
}

I think it may have something to do with indicating the window name, which is different from the existing window.

when the user has 'Let Internet Explorer decide how pop-ups should be open' which is the default, setting resize=yes will make IE9 open a tab and resize=no will allow the popup. this might be the same with other attributes i haven't tested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM