01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.user.client.impl;
17:
18: /**
19: * History implementation for Mozilla-based browsers.
20: */
21: class HistoryImplMozilla extends HistoryImplStandard {
22:
23: @Override
24: public native void newItem(String historyToken) /*-{
25:
26: // When the historyToken is blank or null, we are not able to set
27: // $wnd.location.hash to the empty string, due to a bug in Mozilla.
28: // Every time $wnd.location.hash is set to the empty string, one of the
29: // characters at the end of the URL stored in $wnd.location is 'eaten'.
30: // To get around this bug, we generate the module's URL, and we append a '#'
31: // character onto the end. Without the '#' character at the end of the URL,
32: // Mozilla would reload the page from the server.
33: if (historyToken == null || historyToken.length == 0) {
34: var s = $wnd.location.href;
35: // Pull off any hash.
36: var i = s.indexOf('#');
37: if (i != -1)
38: s = s.substring(0, i);
39:
40: $wnd.location = s + '#';
41: } else {
42: $wnd.location.hash = encodeURIComponent(historyToken);
43: }
44: }-*/;
45: }
|