Anchor Point, Http://localhost:8000/Demo1/js the anchor point in the address bar. Html#a jump to the specified location can be the name of the <a> tag or the ID of the tag.
I've seen a page with an anchor, but it's hard to see the tag in the code for the name or ID for that anchor point. On the Internet a check, the original can use Window.location.hash this is to get or set the anchor point. Is this not a solid foundation of performance? There's this thing on the W3school.
Look at the code
<!DOCTYPE HTML><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head> <Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /> <title>JS Anchor Point</title> <Scriptsrc= "Js/jquery-1.9.1.min.js"></Script> <Scripttype= "Text/javascript"> $(function () { $("#demo a"). On ("Click", function () { var Self= $( This); varHash=self.attr ("href"). Split ('#')[1]; Window.location.hash= "m -" +Hash; }); }); </Script></Head><Body> <DivID= "Demo"> <ahref= "#a">Jump A</a> <ahref= "#b">Jump B</a> </Div> <Divstyle= "Height:500px;background-color: #00ced1"></Div> <DivID= "M-a"style= "Height:200px;background-color: #b6ff00"> </Div> <DivID= "M-b"style= "Height:200px;background-color: #808080"> </Div></Body></HTML>
There is a small problem, the address bar has an anchor point when the F5 refresh page does not jump to the specified location, you can do so.
$ (function () { var hash = Window.location.hash; var id = hash.split (' # ') [1]; if (ID) { var t = $ (' #m-' + ID). Offset (). Top; $ (window). scrolltop (t); } });
This will make the refresh jump past. This method can also be modified, add an animation, point the anchor point after the page slowly go to the anchor point.