KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > user > client > impl > HistoryImplMozilla


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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   public native void newItem(String JavaDoc historyToken) /*-{
24
25     // When the historyToken is blank or null, we are not able to set
26     // $wnd.location.hash to the empty string, due to a bug in Mozilla.
27     // Every time $wnd.location.hash is set to the empty string, one of the
28     // characters at the end of the URL stored in $wnd.location is 'eaten'.
29     // To get around this bug, we generate the module's URL, and we append a '#'
30     // character onto the end. Without the '#' character at the end of the URL,
31     // Mozilla would reload the page from the server.
32     if (historyToken == null || historyToken.length == 0) {
33       var s = $wnd.location.href;
34       // Pull off any hash.
35       var i = s.indexOf('#');
36       if (i != -1)
37         s = s.substring(0, i);
38
39       $wnd.location = s + '#';
40     } else {
41       $wnd.location.hash = encodeURIComponent(historyToken);
42     }
43   }-*/
;
44 }
45
Popular Tags