Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Chrome "window.open" workaround?

I have been working on a web app and for part of it I need to open a new window. I have this working on all browsers, my sticking point is with Google Chrome.

Chrome seems to ignore the window features which is causing me issues, the thing I'm struggling with is I need the address bar to be editable within the new window. FF, IE, Safari and Opera do this fine, Chrome does not.

My Code:

function popitup(url) {   newwindow=window.open(url, 'name', 'toolbar=1,scrollbars=1,location=1,statusbar=0,menubar=1,resizable=1,width=800,height=600');   if (window.focus) {     newwindow.focus()   }   return false; } 
like image 863
Paul Avatar asked Apr 03 '10 19:04

Paul


People also ask

How do I make Chrome open a new window every time?

In the top right corner, you will find the Settings button, select it and from the drop-down menu, select Search settings. Scroll down to the new page that opens, and make sure that the Open New Window for each result is set to Unchecked.


1 Answers

The other answers are outdated. The behavior of Chrome for window.open depends on where it is called from. See also this topic.

When window.open is called from a handler that was triggered though a user action (e.g. onclick event), it will behave similar as <a target="_blank">, which by default opens in a new tab. However if window.open is called elsewhere, Chrome ignores other arguments and always opens a new window with a non-editable address bar.

This looks like some kind of security measure, although the rationale behind it is not completely clear.

like image 181
Jeroen Ooms Avatar answered Sep 29 '22 23:09

Jeroen Ooms