Window.location.hash page jump, accurate positioning, examples show:

Source: Internet
Author: User

Window.location.hash page jump, accurate positioning, examples show:
(1), index.phtml, page for reference

<ScriptID= "Bb_list_template"type= "Text/x-dot-template"><a title="Click to view baby details"href="<?php echo app_web_index_root?>/item/itemdetail<?php echo html_type;? >?qntag=1#iid=<%=it.num_iid%>&&state=<%=it.status%>&&page=<%=it.page%> "ID="title_<%=it.num_iid%>"><%=It.title%></a></Script>


(2), index.js, to get the parameter
/**
*window.location.hash definition and usage
*location is a built-in object that manages the address bar inside JavaScript.
* For example, location.href the URL of the management page, with Location.href=url you can directly redirect the page URL. The
* and Location.hash can be used to get or set the label value of the page. such as http://domain/#admin的location. hash= "#admin". The
*
*substr defines and uses the
*substr () method to extract a specified number of characters from the start subscript in a string.
* Syntax Stringobject.substr (start,length)
*start required. The starting subscript for the substring to extract. Must be numeric. If it is a negative number, the argument declares the position from the end of the string.
* That is,-1 refers to the last character in the string, 2 refers to the second-lowest character, and so on. The
*length is optional. The number of characters in the substring. Must be numeric. If this argument is omitted, then the string from the beginning of the stringobject to the end is returned.
*/

var Shash = window.location.hash.substr (1), var params = shash.split (' & '), var map = new HashMap (); for (var i in params) {var p = params[i].split ("="), if (p.length = = 2) {map.put (p[0], p[1]);}}  Num_iid = Map.get (' iid ');d etailstate = map.get (' state '); if (detailstate = = ' Chuc ' | | detailstate = ' Chus ' | | detailstate = = ' Cangk ' | | Detailstate = = ' Shouw ') {$ (' #deatailback '). Show (); page = map.get (' page ');

(3), return button for positioning

<a class= "sui-btn btn-bordered btn-primary" style= "Display:none ()" id= "Deatailback" href= "Javascript:bblist ()" > Back home </a>/*** [bblist Jump Home]*/function bblist () {document.location.href = App_web_index_root_cdn + ' INDEX ' + HTML _type + '? qntag=1#detailstate= ' + detailstate + ' &page= ' + page + ' &itemid= ' + num_iid;}

  

Window.location.hash page jump, accurate positioning, examples show:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.