Thursday, June 21, 2012

Re: Window.open() opens as a popup


Hi,

Directly call of Window.open() works perfectly to avoid popup blocker, but I need to fetch URL with RPC call
 onClick of the same button and open a new window, if I set global variable to set URL and pass in Window.open() then it takes double click to open newWindow, how can I achieve all with a single click of button?

thanks,
Vishal Dave

On Tuesday, April 24, 2012 10:33:51 PM UTC+5:30, Jens wrote:
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.

--
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/-/9OeX-E7HA6YJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment