简体   繁体   中英

GWT: how can I change browser tab name?

I know that to change the name of the tab in which browser opens the site I need to to change the title tag in the html file.

But in GWT the things are a bit different: each new place uses the same html file, so the browser tab's name will be the same for all the places.

  1. How can I specify a name for each of my places?
  2. This idea above do not work in IE 9. In IE 9 I see www.my-site.com/#my-place-name: name of the browser tab displayed instead of the contents of title tag. How can I make it work for IE too?

You can alter the title of the page with the following code

Window.setTitle("My Place Name");

Do notice that the place who call this the latest will set its title.

You can change the page title (eg "Tab Name") by a call to a static function in GWT:

import com.google.gwt.dom.client.Document;
...
public static void setBrowserWindowTitle (String newTitle) {
    if (Document.get() != null) {
        Document.get().setTitle (newTitle);
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM