1, and to move smoothly through a transmission parameter to jump to a page anchor
// Get the name of the parameter equal to the desired parameter pname according to the parameter name
function getParam(pname) {
var the params location.search.substr = (. 1); // acquisition parameters flat and removed?
var ArrParam = params.split('&');
if (ArrParam.length == 1) {
// where only one parameter
return params.split('=')[1];
}
else {
A plurality of parameters // Parameters
for (var i = 0; i < ArrParam.length; i++) {
if (ArrParam[i].split('=')[0] == pname) {
return ArrParam[i].split('=')[1];
}
}
}
}
// get and move to anchor
$(function() {
var MAO = $ ( "#" + getParam ( "m" )); // get the anchor
IF (mao.length> 0) { if // the object exists is determined
was pos = mao.offset (). top;
var poshigh = mao.height();
$("html,body").animate({ scrollTop: pos-poshigh-30 }, 3000);
}
});
Reproduced in: https: //www.cnblogs.com/guoxiaowen/archive/2012/09/28/JQuery.html