fragment-identifier

URL fragment (#) allowed characters

孤人 提交于 2019-11-27 04:42:22
After some digging on the internet I was unable to find a good answer to which characters I may use for URL fragment. I'm writing a javascript-script that will take advantage of URL fragments. I wanted to make the URL eye-friendly by not having it looking too complicated. So I was wondering if I could use characters like ':, ?, & or !' in the URL fragment and still have it valid. My URL fragment should contain the following values: order-by id desc or asc path /the/full/escaped/path/here/ unor tl;dr The fragment identifier component can contain: 0 - 9 a - z A - Z ? / : @ - . _ ~ ! $ & ' ( ) *

How can I remove the location hash without causing the page to scroll?

筅森魡賤 提交于 2019-11-27 04:10:57
问题 Is it possible to remove the hash from window.location without causing the page to jump-scroll to the top? I need to be able to modify the hash without causing any jumps. I have this: $('<a href="#123">').text('link').click(function(e) { e.preventDefault(); window.location.hash = this.hash; }).appendTo('body'); $('<a href="#">').text('unlink').click(function(e) { e.preventDefault(); window.location.hash = ''; }).appendTo('body'); See live example here: http://jsbin.com/asobi When the user

Smooth scroll to anchor after loading new page

喜欢而已 提交于 2019-11-27 00:22:38
问题 I want to navigate to an anchor point on a new page, but I want the page to load at the top then immediately smooth scroll to the relevant anchor point. Can this be done? I am a complete newbie with Javascript. This is the js I currently use for smooth scrolling within the current page. I just apply a class of 'scroll' on the link. Thanks very much! <script> $(function(){ $('.scroll').on('click',function(e) { e.preventDefault(); $('html, body').animate({ scrollTop: $($(this).attr('href'))

Change hash without reload in jQuery

巧了我就是萌 提交于 2019-11-26 19:17:12
问题 I have the following code: $('ul.questions li a').click(function(event) { $('.tab').hide(); $($(this).attr('href')).fadeIn('slow'); event.preventDefault(); window.location.hash = $(this).attr('href'); }); This simply fades a div in based on when you click but I want the page URL hash tag to change when you click so people can copy and bookmark it. At the moment this effectively reloads the page when the hash tag is change. Is it possible to change the hash tag and not reload the page to

changing location.hash with jquery ui tabs

↘锁芯ラ 提交于 2019-11-26 18:02:13
问题 I've been trying to find a way to change the window.location.hash to the currently selected tab in Jquery UI Tabs. I've tried: $("#tabs > ul").tabs(); $("#tabs > ul").bind("tabsshow", function(event, ui) { window.location.hash = ui.tab; }) This results in changing the hash to #undefined when the tab is changed. I've also tried: $("#tabs > ul").tabs({ select: function(event, ui) { window.location.hash = ui.tab } }); But this doesn't seem to be triggered at all. Any help would be appreciated.

Keeping history of hash/anchor changes in JavaScript

安稳与你 提交于 2019-11-26 17:57:22
问题 I'm currently implementing a JavaScript library that keeps track of the history of changes to the hash part in the address bar. The idea is that you can keep a state in the hash part, and then use the back button to go back to the previous state. In most of the recent browsers, this is automatic and you only have to poll the location.hash property for changes (In IE8 you don't even have to do that; you simply attach a function to the onhashchange event.) What I'm wondering is , what different

Remove fragment in URL with JavaScript w/out causing page reload

六月ゝ 毕业季﹏ 提交于 2019-11-26 17:42:03
问题 Background: I have an HTML page which lets you expand certain content. As only small portions of the page need to be loaded for such an expansion, it's done via JavaScript, and not by directing to a new URL/ HTML page. However, as a bonus the user is able to permalink to such expanded sections, i.e. send someone else a URL like http://example.com/#foobar and have the "foobar" category be opened immediately for that other user. This works using parent.location.hash = 'foobar', so that part is

Remove hash from url

一个人想着一个人 提交于 2019-11-26 16:15:21
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# and I dont quite the hash there. not using window.location.hash at all, but when the user comes back to page 1

How does facebook rewrite the source URL of a page in the browser address bar?

匆匆过客 提交于 2019-11-26 15:45:55
Go to http://www.facebook.com/facebook?v=wall , then click on the info tab. The content will be loaded, and the address bar now becomes http://www.facebook.com/facebook?v=info but the webpage didn't reload. At first I think it is Ajax, but my question is, how do you change the address bar without reloading? I know I can change anchor (#wall) using JS but querystring (?v=wall), how? It's using HTML5's new history.pushState() feature to allow the page to masquerade as being at a different URL to that from which it was originally fetched. This seems only to be supported by WebKit at the moment,

URL fragment (#) allowed characters

倾然丶 夕夏残阳落幕 提交于 2019-11-26 14:10:09
问题 After some digging on the internet I was unable to find a good answer to which characters I may use for URL fragment. I'm writing a javascript-script that will take advantage of URL fragments. I wanted to make the URL eye-friendly by not having it looking too complicated. So I was wondering if I could use characters like ':, ?, & or !' in the URL fragment and still have it valid. My URL fragment should contain the following values: order-by id desc or asc path /the/full/escaped/path/here/ 回答1