Bonjour,

Comme je sais les boutons retour et suivant juste le navigateur ne fonctionne pas avec AJAX, utilisation de load() pour recharger juste une partie de la page. Du moins, les pages ne se recharges pas.

J'avais trouvé une solution mais le problème c'est que les pages se chargeaient 2 fois. J'ai supprimé la fonction checkURL() dans le ready et la je ne peux plus retourner sur la page suivante, juste l'url change.

C'est une question fréquente mais je ne vois pas comment résoudre le problème pour moi.

En faite, j'aimerai au clique sur le bouton de retour ou suivant que la page se charge si l'url est différent.

J'avais réglé le problème avec la fonction checkURL(), mais il y avait 2 chargements pour les pages chargés avec clique.

Voici le code js :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
$(document).ready(function(){
    //setInterval(checkURL,250);
    //alert("ready");
});
 
 
$(document).on("click", "#DNAbox", function() {
    //alert("click DNAbox");
    loadPageTheme("theme_page/dna.html");
    return false;
});
 
$(document).on("click", "#HTSbox", function() {
    loadPageTheme("theme_page/hts.html");
    return false;
});
 
$(document).on("click", "#RNAbox", function() {
    loadPageTheme("theme_page/rna.html");
    return false;
});
 
$(document).on("click", "#PROTEINSbox", function() {
    loadPageTheme("theme_page/proteins.html");
    return false;
});
 
$(document).on("click", "#TFMbox", function() {
    loadPageTheme("theme_page/tfm.html");
    return false;
});
 
$(document).on("click", "#NRPbox", function() {
    loadPageTheme("theme_page/nrp.html");
    return false;
});
 
 
var lasturl="";
 
 
//Permet de voir si l'url est toujours la même lors de la mise à jour de la page        
function checkURL()
{
    hash=window.location.hash;
    if(hash != lasturl)
    {
        lasturl=hash;
        if(hash==""){
	    loadPageHome();
	    $('#style_theme').remove();
        }else{
	    //alert(hash);
            loadPage(hash);
	    $('#logos').remove();
        }
    }
}
 
 
//Chargement de la page quand clique sur l'onglet, appelée dans checkURL()              
 
function loadPage(hash){
    //alert("loadPage");
    url=hash.replace('#', '');
    var tab = url.split("/");
    if(tab[0]=="theme_page"){
	loadPageTheme(url);
    }
    else{
	loadPageSoftware(url);
    }
}
 
function loadPageTheme(url_html){
    alert("loadPageTheme");
    $("#menu_left").css("display","block");
    $("#link_menu").css("display","none");
    var tab = url_html.split("/");
    theme_tab=tab[1].split(".")
    theme_maj=theme_tab[0].toUpperCase();
    $("#title").text(theme_maj);
    $("#main").load(url_html);
    $("#footer_left").html('');
    $("#footer_right").html('2013 -<a href="http://www.lifl.fr/bonsai">Bonsai bioinformatics</a>');
    $('#logos').remove();
    $('#style_theme').remove();
    $('#style_soft').remove();
    $("#menu_central").css('display', 'none');
    $("head").append($(document.createElement("link")).attr({rel:"stylesheet", type:"text/css", href:"/Style/css/theme/"+theme_tab[0]+".css", id:"style_theme"}));
    window.location.href="#"+url_html;
}
 
function loadPageHome(){
    alert("loadPageHome");
    $("#center").load("/index.php #center");
    $("#title").text("Bonsai :: Bioinformatics Software Server");
    $("#footer").text("Updated : september 26, 2013");
}
 
 
function loadPageSoftware(url){
    alert("loadPageSoftware");
    hash="#"+url;
    $("#menu_left").css("display","none");
    $("#link_menu").css("display","inline-block");
    tab=url.split("/");
    name_soft=""
    if (tab.length>2){
	name_soft=tab[1];
    }else{
	name_soft=tab[0];
    }
    name_maj=name_soft.toUpperCase();
    url_soft=url;
    url_css="/"+name_soft+"/"+name_soft+".css"
    url_html="/"+url_soft;
    $("#title").text(name_maj);
    $("#main").load(url_html);
    $("#menu_central").load("/"+name_soft+"/menu_central.txt");
    $("#footer_right").html('2013 -<a href="http://www.lifl.fr/bonsai">Bonsai bioinformatics</a>');
    $("#footer_left").html('For questions about <b>'+name_soft+'</b> or for bug reports, please contact <a href="javascript:escramble("'+name_soft+'@lifl.fr")>'+name_maj+'</a>');
    $("#style_soft").remove();
    $("#style_theme").remove();
    $("head").append($(document.createElement("link")).attr({rel:"stylesheet", type:"text/css", href:url_css, id:"style_soft"}));
    $('#logos').remove();
    $("#menu_central").css('display', 'inline-block');
    window.location.href="#"+url_soft;
    setInterval(active_class, 250);
}
 
function active_page(element){
    var anchor = window.location.hash;
    //alert("active_page");
    $(element).each(function(){
	var current = null;
	if (anchor!= ''){
	    current = anchor;
	}else{
	    current=$(this).find('a:first').attr('href');
	}
	//alert("active_page");
	$(this).find('a[href="'+current+'"]').parent().addClass("active");
 
	parent=$(this).find('a[href="'+current+'"]').parent();
	$(this).find("a").click(function(){
	    //$("#menu_left").css("display","none");
	    //$("#link_menu").css("display","block");
	    var link = $(this).attr('href');
	    if (link == current){
		return false;
	    }else{
		$(this).parent().addClass("active");
		$(this).parent().siblings().removeClass("active");
		loadPage(link);
		current=link;
	    }
	});
    });
}
 
//Fonction permettant d'activer l'onglet sélectionné
function active_class(){
    elt_current=".tabs";
    hash=window.location.hash;
    $(elt_current).find('a[href="'+hash+'"]').parent().addClass("active");
    $(elt_current).find('a[href="'+hash+'"]').parent().siblings().removeClass("active");
}
 
 
/*
function loadPageSoft(name_soft){
    alert("loadPageSoft");
    name_maj=name_soft.toUpperCase();
    url_soft=name_soft+"/"+name_soft+".php";
    url_html="/"+url_soft;
    $("#title").text(name_maj);
    $("#main").load(url_html);
    $("#menu_central").load("/"+name_soft+"/menu_central.txt");
    $("#footer_right").html('2013 -<a href="http://www.lifl.fr/bonsai">Bonsai bioinformatics</a>');
    $("#footer_left").html('For questions about <b>'+name_soft+'</b> or for bug reports, please contact <a href="javascript:escramble("'+name_soft+'@lifl.fr")>Test_tuto</a>');
    $('#logos').remove();
    $("#menu_central").css('display', 'block');
    window.location.href="#"+url_soft;
}*/
 
 
//Fonction pour crypter l'adresse mail
function escramble(mail) {
    var a,b,c,d,e,f;
    a=  'mai'; 
    b= 'cg';  
    a+= 'lto:'; 
    c=  'seq';
    d= '@li';
    e= 'fl.fr';
    window.location.href=a+mail+'\?Subject=[MyProgram:Suggestion/Comment/Critics]';
}
 
//fonction qui permet de cacher et monter le menu de gauche en cliquant sur "Menu Software"
function hide_show(id){
    $(id).toggle();
}

Merci.

Alaninho