我已经编写了一段脚本,可以从URL中删除#
并滚动到特定的
。它适用于普通的URL,例如:
有没有想法,怎么解决这个问题?我找不到错误在哪里?
10.0.1.22/dev/pg/blog/all/
但是对于像以下这样的URL,它无法正常工作:
10.0.1.22/dev/pg/search/?tag=a&entity_subtype=blog&entity_type=object&search_type=entities#39531
它没有从URL中删除#
,并且滚动也不起作用。
脚本
jQuery(document).ready(function($) {
$(".full_view_btn").live('click', function(){
var divid = $(this).attr('data-id');
var long_desc = "#inner_descrip" + divid;
var short_desc = "#listing_desp" + divid;
var shw_mre_btn = "#full_view" + divid;
if($(long_desc).is( ':hidden' )){
$('.long_desc').hide();
$('.short_desc').show();
$(long_desc).show();
$(short_desc).hide();
$('.full_view_btn').text('Show more');
$(shw_mre_btn).text('Show less');
} else{
$(long_desc).hide();
$(short_desc).show();
$(shw_mre_btn).text('Show more');
}
if (location.pathname.replace('/^\//','') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[id=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top-60
}, 500);
target.parent().find('#highlight_div'+divid).css("box-shadow", "0 0 2px 1px #cccccc");
setTimeout(function() {
target.parent().find('#highlight_div'+divid).css("box-shadow", "none");
}, 1000);
return false;
}
}
});
});
有没有想法,怎么解决这个问题?我找不到错误在哪里?