diff options
author | Leif Åstrand <leif@vaadin.com> | 2012-10-24 12:31:29 +0300 |
---|---|---|
committer | Leif Åstrand <leif@vaadin.com> | 2012-10-24 12:31:29 +0300 |
commit | e827b05a20fa9effdc23bd9b1aa1d3a0f76e0f4f (patch) | |
tree | 4ef8d1045c97fe9b33501c46076a5de640df474d /client | |
parent | 8e31001c27f47f1bead4f13c4be07615df29993e (diff) | |
download | vaadin-framework-e827b05a20fa9effdc23bd9b1aa1d3a0f76e0f4f.tar.gz vaadin-framework-e827b05a20fa9effdc23bd9b1aa1d3a0f76e0f4f.zip |
Make Util.getAbsoluteUrl work in IE8 (#10049)
Change-Id: Ia473ec5ee9b491fdf6d8bc18de388a3133d7c52e
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/Util.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/client/src/com/vaadin/client/Util.java b/client/src/com/vaadin/client/Util.java index 7aea69a61d..bf4dca7712 100644 --- a/client/src/com/vaadin/client/Util.java +++ b/client/src/com/vaadin/client/Util.java @@ -25,11 +25,13 @@ import java.util.List; import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.dom.client.AnchorElement; +import com.google.gwt.dom.client.DivElement; import com.google.gwt.dom.client.Document; import com.google.gwt.dom.client.NativeEvent; import com.google.gwt.dom.client.Node; import com.google.gwt.dom.client.NodeList; import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Display; import com.google.gwt.dom.client.Touch; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DOM; @@ -1207,8 +1209,23 @@ public class Util { * @return the corresponding absolute URL as a string */ public static String getAbsoluteUrl(String url) { - AnchorElement a = Document.get().createAnchorElement(); - a.setHref(url); - return a.getHref(); + if (BrowserInfo.get().isIE8()) { + // The hard way - must use innerHTML and attach to DOM in IE8 + DivElement divElement = Document.get().createDivElement(); + divElement.getStyle().setDisplay(Display.NONE); + + RootPanel.getBodyElement().appendChild(divElement); + divElement.setInnerHTML("<a href='" + escapeHTML(url) + "' ></a>"); + + AnchorElement a = divElement.getChild(0).cast(); + String href = a.getHref(); + + RootPanel.getBodyElement().removeChild(divElement); + return href; + } else { + AnchorElement a = Document.get().createAnchorElement(); + a.setHref(url); + return a.getHref(); + } } } |