window.open relative url in firefox & ie

801 views
Skip to first unread message

Qweed

unread,
Jul 20, 2007, 12:37:55 AM7/20/07
to Google Web Toolkit
Hi
I am trying to open a relative url with window.open and noticed that
IE and firefox opens different urls

example

project structure
test
/n1
/n2
/gwt.html (host page)
/org.test.Main (all the gwt stuff)
/test.html (the page i am trying to open)

EntryPoint.java
....

public void onModuleLoad() {
final Button button = new Button("open new page");

button.addClickListener(new ClickListener(){
public void onClick(Widget w) {
//seems to use host page url
Window.open("./test.html", "", "");
}
});


RootPanel.get().add(button);
}

....

IE button click gives
http://localhost:8080/test/org.test.Main/test.html

firefox button click gives
http://localhost:8080/test/n1/n2/test.html

using gwt 1.3.3, java app server

what am i doing wrong here?? did i forget to set some startup params
or is this a bug??

Any tips would be helpful.
Thanks,

Robert Hanson

unread,
Jul 20, 2007, 7:38:57 AM7/20/07
to Google-We...@googlegroups.com
Try using either GWT.getHostPageBaseURL() or GWT.getModuleBaseURL()
when opening a new window. The first is the the directory where the
host page is, and the second is where the JS code is.

Given the dir structure you provided, I think this is what you want.

Window.open(GWT.getHostPageBaseURL() + "/../test.html", "", "");

Rob
http://roberthanson.name

Reply all
Reply to author
Forward
0 new messages