Hyperlink widget doesn't work with IE

18 views
Skip to first unread message

Vikas Garg

unread,
Nov 28, 2007, 4:04:52 AM11/28/07
to Google Web Toolkit
Hyperlink link = new Hyperlink(str, "hyperlink");
link.setStyleName("Hyperlink-Style");
link.setHTML("<HTML><Body><a href=\"http://www.google.com" + "\">" +
"Link" + </a></Body></HTML>");

.Hyperlink-Style {
color:black;
text-decoration:underline;
cursor:pointer;
}

When i use this code, the hyperlink doesn't show up in IE. It's
working fine with Mozilla Firefox.

Rob Coops

unread,
Nov 28, 2007, 6:27:12 AM11/28/07
to Google-We...@googlegroups.com
Please have a look at the documentation for this widget, and for GWT in general.
 
You are creating a new <HTML> and <BODY> tag inside the body of a HTML document, the fact that this works in firefox is just because firefox handels invallid HTML code different the IE does.

Vikas Garg

unread,
Nov 28, 2007, 6:37:24 AM11/28/07
to Google Web Toolkit
I am not sure if the problem lies with creating new tags here. Infact
i checked it without <HTML> and <BODY> tag, it still doesn't work!!
If there is any other way of setting the target for a hyperlink,
please let me know.

On Nov 28, 4:27 pm, "Rob Coops" <rco...@gmail.com> wrote:
> Please have a look at the documentation for this widget, and for GWT in
> general.
>
> You are creating a new <HTML> and <BODY> tag inside the body of a HTML
> document, the fact that this works in firefox is just because firefox
> handels invallid HTML code different the IE does.
>

Vikas Garg

unread,
Nov 28, 2007, 7:32:55 AM11/28/07
to Google Web Toolkit
The workaround in this case may be using HTML widget instead of
HyperLink widget. HTML widget works fine.

David Clément

unread,
Nov 28, 2007, 8:02:30 AM11/28/07
to Google-We...@googlegroups.com

sal...@gmail.com

unread,
Nov 28, 2007, 9:18:40 AM11/28/07
to Google Web Toolkit
Vikas,

If I remember correctly, the GWT Hyperlink does not appear as a <a> in
the generated HTML. Instead, it is a <div> with a javascript event
handler attached to it. I believe that overwriting the HTML (using
DOM.setInnerHTML and possibly Hyperlink.setHTML) detaches the
javascript event handler. And as mentioned by other posters, this is
probably not what you want. The Hyperlink creates history tokens and
only goes to internal states of the app. This behavior is misleading,
and we stopped using the widget altogether. We wrote
our own SimpleHyperlink class that uses an <a> HTML tag as one would
expect a hyperlink to do, and it behaves wonderfully in all browsers.

Hope that helps,
David
Reply all
Reply to author
Forward
0 new messages