0

I am trying to open a URL in a new window. The URL is opened in a new window but without any Menu and navigation controls.

JS Code to open URL in new Window

URL opened in new TAB

JSFiddle: https://jsfiddle.net/Sahil_Gupta/nfuehqv1/2/

I am using JAVA and ZK in backend and using Script to run the code as:

    Script jsScriptInitializer = new Script();
    String js = "window.open('https://www.google.com', '_blank', 'location=no,scrollbars=yes,toolbar=yes,menubar=yes,resizable=yes');";     
    jsScriptInitializer.setContent(js);
    jsScriptInitializer.setDefer(true);
    jsScriptInitializer.setParent(event.getTarget().getParent().getParent());

I need all the navigation and menu controls as usual when I open a URL in another window. How can I achieve this ?

Olivier
  • 13,283
  • 1
  • 8
  • 24
Sahil Gupta
  • 73
  • 1
  • 3
  • 12
  • Why not simple `window.open('https://www.google.com')`? This [discussion](https://stackoverflow.com/a/14643184/15273968) may help. – the Hutt Jan 24 '22 at 10:44
  • It opens in a new Tab. I need to open in new window. – Sahil Gupta Jan 24 '22 at 13:29
  • @SahilGupta are you trying to open a new chrome window instead of popup? If so its not possible with javascript. you can instantiate new chrome instance by java. – PRAJIN PRAKASH Jan 31 '22 at 08:14

1 Answers1

2

Your code will work as desired in browsers other than Chrome. There has been an ongoing bug in Chrome which has turned into a feature request. You can read about it at: https://bugs.chromium.org/p/chromium/issues/detail?id=82522

As of Jan 2022, there is still no way to open a Seperate window with the standard toolbars. However, if you can accept the new window being in the form of a tab rather than a separate window, simply eliminating the third argument will open as a fully featured tab.

// open a new tab
window.open('https://www.google.com', '_blank'); 
factorypolaris
  • 2,757
  • 12
  • 15