我正在使用jquery $ .ajax开发网站来加载我在content /目录中的不同页面的内容.我还使用hashtags来激活后退按钮,重新加载等.
但.我有主菜单和活动项目,如果我在一个主菜单项的深度页面之间导航,它是活动的.然后,我单击其中一个主菜单项,例如"联系人".因此,联系人菜单项变为活动状态.如果我单击浏览器后退按钮,活动菜单项将不会更改.
那么,有没有办法记住活动主菜单项的状态?主菜单位于容器页面上.
谢谢!
$(function(){
$('.menu a')
.bind('click',function(e) {
e.preventDefault();
$('#content').html('????????, ???????? ?? ?????????? ??? ????????? ? ??????????!');
$('.menu a').each(function() {$(this).removeClass('activelink');});
location.hash=$(this).attr('href').match(/(([a-z]*)\W)*/)[2];
$(this).addClass('activelink');
return false;
});
$('#content').on('click','a',function(e) {
if (!($(this).hasClass('address') || $(this).hasClass('zoom'))){
e.preventDefault();
$('#content').html('????????, ???????? ?? ?????????? ??? ????????? ? ??????????!');
location.hash=$(this).attr('href').match(/(([a-z]*)\W)*/)[2];
return false;
}
else {
if ($(this).hasClass('address')) {
alert('?? ????????? ???? The House Of Events. ????????????? ? ??? ???!');
}
}
});
function hashChange(){
var page=location.hash.slice(1);
if (page!=""){
$.ajax({
type: "GET",
url: "content/" + page …Run Code Online (Sandbox Code Playgroud)