On Jan 8, 12:29 pm, John Patterson <jdpatter...@gmail.com> wrote: > On 8 Jan 2010, at 16:22, Thomas Broyer wrote: > > > Use Hyperlink or InlineHyperlink widgets for "internal > > navigation" (unless you also want ClickHandlers, in which case Anchor > > is fine, calling History.newItem() in a ClickHandler, but do not > > forget to ClickEvent#preventDefault() // this is more or less what > > Hyperlink/InlineHyperlink widgets do). > > Using Anchors caused onWindowClosing() to be called in IE7/8 so I > could not use them. Using Button has solved this so far although I > have a lot of default CSS to override. I just tested with Hyperlink > as you suggested and this also works fine. Perhaps the difference is > that it uses "#" as the href rather than "javascript:;" so IE > recognises this as an internal link.
No, the reason is that it ClickEvent#preventDefault() in a ClickHandler. If you do the same with an Anchor in your ClickHandler, it'll work too. Hyperlink/InlineHyperlink though has some differences with Anchor that make it worth it: - the link's href="" is the history token the Hyperlink targets, so you can right-click -> open in new window (or tab), or ctrl+click or middle-click or whatever to open the link in another window/tab; and you can of course also drag'n'drop the link into another application to have a direct URL to the "page" targeted by the Hyperlink - the ClickHandler only ClickEvent#preventDefault() under some conditions, so that the right-click, middle-click and ctrl+click work OK (and the conditions are different depending on the browser, thanks to GWT's "deferred binding" feature) If you don't want this behavior, then a Button or Label/InlineLabel would be more appropriate than Anchor or Hyperlink/InlineHyperlink.
-- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to google-web-tool...@googlegroups.com. To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.