2012-02-08 20 views

答えて

7

jquery.history.jsライブラリで、テスト目的で同じことを行い、次の行を更新しました。

オリジナル:(View on GitHub

m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)} 

ハックソリューション:

m.emulated={pushState:true,hashChange:true} 

私はHTML4 + HTML5バンドル縮小さのコードを使用していますが、行は269行目に対応history.js圧縮されていないファイルあなたが別のバージョンを使用している場合は、対応するセクションはここにある:

Unminifiedオリジナル(View on GitHub):

History.emulated = { 
pushState: !Boolean(
window.history && window.history.pushState && window.history.replaceState 
&& !(
(/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */ 
|| (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */ 
) 
), 
hashChange: Boolean(
!(('onhashchange' in window) || ('onhashchange' in document)) 
|| 
(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8) 
) 
}; 

ハックソリューション:

History.emulated = { 
    pushState: true, 
    hashChange: true 
    }; 
+0

素晴らしいです。ありがとう! – stubotnik

+0

なぜこのような設定をしないのですか?誰もが '#'バージョンが動作することを望んでいるようですね? –

+1

@ JamieHutberブラウザが劣化すると、ハッシュにフォールバックします。これらのコード変更は通常、プッシュ状態を使用するHTML5ブラウザのハッシュバージョンを強制的に**強制します。 – dazbradbury

関連する問題