fragment-identifier

Parsing URL hash/fragment identifier with JavaScript

谁说我不能喝 提交于 2019-11-26 13:02:23
Looking for a way to parse key pairs out of the hash/fragment of a URL into an object/associative array with JavaScript/JQuery Hovis Biddle Check out: jQuery BBQ jQuery BBQ is designed for parsing things from the url (query string or fragment), and goes a bit farther to simplify fragment-based history. This is the jQuery plugin Yarin was looking for before he put together a pure js solution. Specifically, the deparam.fragment() function does the job. Have a look! (The support site I'm working on uses an asynchronous search, and because BBQ makes it trivial to tuck entire objects into the

Getting URL hash location, and using it in jQuery

瘦欲@ 提交于 2019-11-26 12:53:04
I'd like to get the value after a hash in the URL of the current page and then be able to apply this in a new function... eg. The URL could be www.example.com/index.html#foo And I would like to use this in conjunction with the following piece of code $('ul#foo:first').show(); I'm kinda assuming/hoping there is some way of grabbing this, and turning it into a variable that I can then use in the second piece of code. CMS Editor's note: the approach below has serious security implications and, depending upon the version of jQuery you are using, may expose your users to XSS attacks. For more

Handle URL anchor change event in js

↘锁芯ラ 提交于 2019-11-26 12:04:57
How can I write the JavaScript callback code that will be executed on any changes in the URL anchor? For example from http://example.com#a to http://example.com#b Google Custom Search Engines use a timer to check the hash against a previous value, whilst the child iframe on a seperate domain updates the parent's location hash to contain the size of the iframe document's body. When the timer catches the change, the parent can resize the iframe to match that of the body so that scrollbars aren't displayed. Something like the following achieves the same: var storedHash = window.location.hash;

What are the differences between history.pushState & location.hash?

旧城冷巷雨未停 提交于 2019-11-26 11:05:54
问题 I\'m trying to update the URL using either window.location.hash or history.pushState . What are the differences / advantages of each? 回答1: location.hash has a better support than the history.pushState method. The advantage of the pushState method is that you can bind a state to the history entry. If you don't need this state object, I recommend to use the location.hash property, to have a better compatibility with older browsers. location.hash = 'new-hash'; console.log(history.state); // null

List of valid characters for the fragment identifier in an URL?

穿精又带淫゛_ 提交于 2019-11-26 08:07:01
问题 I\'m using the fragment identifier to create a permalink for AJAX events in my web app similar to this guy. Something like: http://www.myapp.com/calendar#filter:year/2010/month/5 I\'ve done quite a bit of searching but can\'t find a list of valid characters for the fragment idenitifer. The W3C spec doesn\'t offer anything. Do I need to encode the characters the same as the URL in has in general? There doesn\'t seem to be any good information on this anywhere. 回答1: See the RFC 3986. fragment =

Getting URL hash location, and using it in jQuery

时光总嘲笑我的痴心妄想 提交于 2019-11-26 05:54:36
问题 I\'d like to get the value after a hash in the URL of the current page and then be able to apply this in a new function... eg. The URL could be www.example.com/index.html#foo And I would like to use this in conjunction with the following piece of code $(\'ul#foo:first\').show(); I\'m kinda assuming/hoping there is some way of grabbing this, and turning it into a variable that I can then use in the second piece of code. 回答1: Editor's note: the approach below has serious security implications

Remove hash from url

点点圈 提交于 2019-11-26 04:45:41
问题 I am ajax-ifying the pagination in one of me projects and since I want the users to be able to bookmarks the current page, I am appending the page number via hash, say: onclick=\"callPage(2); window.location.hash=\'p=2\'; return false;\" and thats on the hyperlink it works fine and everything, except, when the page number is 1, i dont want to URL to be /products#p=1 , I just want it to be /products I tried these variations: window.location.hash=\'\' works but the url is now like /products#

Parsing URL hash/fragment identifier with JavaScript

♀尐吖头ヾ 提交于 2019-11-26 03:10:00
问题 Looking for a way to parse key pairs out of the hash/fragment of a URL into an object/associative array with JavaScript/JQuery 回答1: Check out: jQuery BBQ jQuery BBQ is designed for parsing things from the url (query string or fragment), and goes a bit farther to simplify fragment-based history. This is the jQuery plugin Yarin was looking for before he put together a pure js solution. Specifically, the deparam.fragment() function does the job. Have a look! (The support site I'm working on uses

How to show Ajax requests in URL?

你说的曾经没有我的故事 提交于 2019-11-26 02:07:33
问题 What I want is to have links which change a part of the page , and a dynamic URL for it, where I can specify variables such like #calendar=10_2010tabview=tab2 Check this for an exact example: CLICK HERE FOR EXACT DEMO So here is the link format what I need: #calendar=10_2010&tabview=tab2 I need to have variables in the links like calendar and tabview so I can change multiple things on a single page without realoading. Or another format such like on http://www.wbhomes.com.au , this is exactly

Detecting Back Button/Hash Change in URL

大憨熊 提交于 2019-11-26 00:58:25
问题 I just set up my new homepage at http://ritter.vg. I\'m using jQuery, but very minimally. It loads all the pages using AJAX - I have it set up to allow bookmarking by detecting the hash in the URL. //general functions function getUrl(u) { return u + \'.html\'; } function loadURL(u) { $.get(getUrl(u), function(r){ $(\'#main\').html(r); } ); } //allows bookmarking var hash = new String(document.location).indexOf(\"#\"); if(hash > 0) { page = new String(document.location).substring(hash + 1); if