For example, to jump to the mao.aspx page div id= "s" position then only with <a href= "mao.aspx#s" > can be implemented to jump to the specified location
Now in order to increase the user experience to jump to the page after the smooth move to that location how to do it is actually very simple to pass over there a parameter to jump to which div on the line
First on a page to get the parameters of the Universal JS
Copy CodeThe code is as follows:
Get the parameter pname equals the desired parameter name according to the argument name
function GetParam (pname) {
var params = location.search.substr (1); Get the parameters flat and remove?
var arrparam = params.split (' & ');
if (arrparam.length = = 1) {
Case with only one parameter
return params.split (' = ') [1];
}
else {
Conditions for multiple parameter parameters
for (var i = 0; i < arrparam.length; i++) {
if (arrparam[i].split (' = ') [0] = = pname) {
return arrparam[i].split (' = ') [1];
}
}
}
}
The code is simple enough to get the value of the desired parameter from the current URL.
Copy CodeThe code is as follows:
$ (function () {
var Mao = $ ("#" + GetParam ("M")); Get anchor Points
if (Mao.length > 0) {//Determine if object exists
var pos = Mao.offset (). Top;
var Poshigh = Mao.height ();
$ ("Html,body"). Animate ({scrolltop:pos-poshigh-30}, 3000);
}
});
Above is the smooth move to the desired position pos-poshigh-30 This can be adjusted I think it's a good thing to lose to 30.
Very simple effect not on the code example of their own writing to play ~
Implementation code for a jquery-based jump from one page to the specified location on another page