Window.open() opens as a popup

647 views
Skip to first unread message

Deepak Singh

unread,
Apr 22, 2012, 2:27:51 PM4/22/12
to google-we...@googlegroups.com
Hi,

I am using Window.open('Url', "_blank", "");

It always opens the new window as popup. I want this to be opened as a new tab, browser window. It should not react with popup blocker anymore.

How can i achieve this one ?


Thanks
Deepak Singh

Jens

unread,
Apr 22, 2012, 4:50:02 PM4/22/12
to google-we...@googlegroups.com
A popup blocker will always jump in if you execute window.open() without direct user interaction. If you want to avoid a popup blocker you have to provide a link the user can click on and inside the click handler open the new window.

Beside that, you can't force the browser to open a new tab through javascript. Its a user specific setting inside the browser. 

CSS3 seems to provide something in this direction but its not supported in any browser: http://www.w3schools.com/cssref/css3_pr_target-new.asp

-- J.

Deepak Singh

unread,
Apr 22, 2012, 5:37:12 PM4/22/12
to google-we...@googlegroups.com
But same thing i am doing with button click handler instead a link.

User clicks on a button, i perform some task and the open the new window inside click handler of button.

Does it make any difference in case of click handler of a link instead of button ?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/MX73-2UWBvsJ.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.



--
Deepak Singh

Deepak Singh

unread,
Apr 24, 2012, 12:26:26 PM4/24/12
to google-we...@googlegroups.com
Still no luck.

Any solution pls.
--
Deepak Singh

Jens

unread,
Apr 24, 2012, 1:03:51 PM4/24/12
to google-we...@googlegroups.com
You have to make sure that you directly call Window.open() in the ClickHandler. Don't to it in a Timer, deferred command or similar inside the ClickHandler. The Browser must recognize that Window.open() is directly called because of a user action. It does not matter if its a Button or an Anchor.
Also don't do Window.open() somewhere deep in a sub function called inside the ClickHandler.

Something like the following will work:

Button b = new Button("Test");
b.addClickHandler(new ClickHandler() {
  void onClick(ClickEvent e) {
    Window.open("http://www.google.de", "_blank", "");
  }
});

If you wrap Window.open() for example in a Timer it won't work anymore.

-- J.
Reply all
Reply to author
Forward
0 new messages