Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
function getNameBrouser() {
var userAgent = navigator.userAgent.toLowerCase();
// Определим Internet Explorer
//...весь остальной код
return "unknown";
}
$jQuery("a").click(function(){
if($jQuery(this).attr("href").substr(0, 1) == "/"){
if(getNameBrouser() == "gecko"){
window.history.pushState("", "", $jQuery(this).attr("href"));
window.history.replaceState("", "", $jQuery(this).attr("href"));
get_page_by_hash($jQuery(this).attr("href"));
}else{
window.location.hash = $jQuery(this).attr("href");
}
}
});
function has_history_api() {
return !!(window.history && history.pushState);
}
$jQuery("a").click(function(){
if($jQuery(this).attr("href").substr(0, 1) == "/"){
if(has_history_api()){
window.history.pushState("", "", $jQuery(this).attr("href"));
window.history.replaceState("", "", $jQuery(this).attr("href"));
get_page_by_hash($jQuery(this).attr("href"));
}else{
window.location.hash = $jQuery(this).attr("href");
}
}
});
jQuery("a").click(function(){
var href = jQuery(this).attr("href");
if( href.indexOf('/') != 0 ) return;
if ( window.history && history.pushState ) {
history.pushState ("", "", href);
history.replaceState("", "", href);
get_page_by_hash(href);
} else {
location.hash = href;
}
});
$("a").click(function(){
var href = $(this).attr("href");
if( href.indexOf('/') != 0 ) return;
if ( window.history && history.pushState ) {
history.pushState ("", "", href);
history.replaceState("", "", href);
get_page_by_hash(href);
} else {
location.hash = href;
}
});
$("a").click(function()
{
$.ajax({
data:{'isajax':true;}
url:$(this).attr('href');
success:function(data){
$("#container").html(data);
}
});
});
$jQuery = jQuery.noConflict();, когда уже есть глобальная переменная jQuery? Тупняк — лишняя переменная, лишний байт, смысла ноль.$(window).bind('hashchange') без всяких плагинов. getNameBrouser() уже прошлись выше.
Загрузка страницы с помощью Ajax как ВКонтакте