0

I am adding the following javascript at runtime to open a new browser window. I know window.open is available in javascript. But it doesn't work for safari and chrome. Is there any other trick or hooking technique to achieve this.

     string script= "window.open('http://www.w3schools.com','_blank','toolbar=yes,location=yes,directories=no,status=1,menubar=yes,scrollbars=yes,resizable=no,copyhistory=yes,left=20,top=20,width=600,height=550');";

ScriptManager.RegisterStartupScript(this, this.GetType(), "newWindowScript",  script, true);

Thanks

Bilal lilla
  • 618
  • 3
  • 8
  • 29

2 Answers2

0

This is because of the popup blocker in the browser. You can use Ajax Modal Popup window instead of Window.Open

http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/ModalPopup/ModalPopup.aspx

Another option is Jquery popup http://yensdesign.com/2008/09/how-to-create-a-stunning-and-smooth-popup-using-jquery/

if you still need to use Window.Open then please refer this

Bypass popup blocker on window.open when JQuery event.preventDefault() is set

Community
  • 1
  • 1
PraveenVenu
  • 8,217
  • 4
  • 30
  • 39
0

window.open() most certainly works in Safari and Chrome, I used it today! The demos on the w3Schools site work in Chrome

Try moving the code into a standard in-page <script> block (obviously with the .net stuff removed) to test and see if you get any errors in the console.

It could be that one of the features you are passing as the 3rd argument to .open() is breaking things (like the copyhistory feature - I never saw that before, and it isn't listed in the available options on the w3Schools site)? I have noticed that Chrome tends to ignore the width and open it to whatever size it wants to...

danwellman
  • 9,068
  • 8
  • 60
  • 88