ブラウザの戻るボタンを聞いて前のページをロードするためのスクリプトを作成しています。私はjqueryとjavascript(phpの人)に不慣れです。これを再発明する前に、私はWeb全体でライブラリを検索しました。しかし、ajaxリンクで多くのパラメーターを使用しているため、それらのライブラリーを使用することはできません。私はそのような複雑なシステムの使い方がわからないので、私の間違いを認めます。ですから、次のようなシステムを作っていくのではないかと考えています。
// get the contents of a particular div and save as an object/associative array
// { hash : pageNumber, html : content}
function save_history(div){
var content = $(div).html();
// increment the page number and add hash tags to the URL
}
// Listen to the browser hash value change
$(window).bind('hashchange', function () {
hash = window.location.hash;
if(hashValue){
load_history(hashValue);
}
});
// Load data from history
function load_history(id){
// fetch the content based on the hashvalue
$(div).html(content);
}
これを使用することに問題はありますか?多くのコンテンツがオブジェクトとして保存されている場合、これによりページが応答しなくなったり、ブラウザがクラッシュしたりしますか?そのような問題が発生した場合、私は時間を無駄にしたくありません。