fragment-identifier

Change hash without reload in jQuery

徘徊边缘 提交于 2019-11-27 18:06:21
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 prevent the jumping effect? This works for me $('ul.questions li a').click(function(event) { event

Bootstrap Collapse - open the given id fragment

。_饼干妹妹 提交于 2019-11-27 17:23:24
问题 Imagine a Bootstrap collapse with 3 parts <div class="panel-group" id="accordion"> ... <div id="accordionOne" class="panel-heading"></div> ... <div id="accordionTwo" class="panel-heading"></div> ... <div id="accordionThree" class="panel-heading"></div> </div> Is there a simple way to make the plugin open the given HTTP fragment identifier ? Example http://myproject/url#accordionTwo would open the second accordion 回答1: $("#accordionTwo").collapse('show'); To open the given HTTP fragment

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

主宰稳场 提交于 2019-11-27 17:09:24
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 clicks ' link ' the hash tag is modified without any page jumps, so that's working fine. But when the user

Retrieve the fragment (hash) from a URL and inject the values into the bean

ⅰ亾dé卋堺 提交于 2019-11-27 13:50:25
问题 I am looking for a way to inject values from the fragment (#) of a URL into bean(JSF), in the same way query-parameter values are injected. I am using Ben Alman's Bookmarkable jQuery plugin (http://benalman.com/projects/jquery-bbq-plugin/) to create the URL fragments. I was hoping that Custom regex patterns from prettyFaces could be a way to solve my problem but until now I have been unsuccessful. (http://ocpsoft.com/docs/prettyfaces/snapshot/en-US/html_single/#config.pathparams.regext) I

What's the best library to do a URL hash/history in JQuery? [closed]

Deadly 提交于 2019-11-27 12:06:44
I've been looking around JQuery libraries for the URL hash, but found none that were good. There is the "history plugin", but we all know it's buggy and isn't flexible. I am loading my pages inside a div. I'll need a way to do back/forward along with the url hashing. mydomain.com/#home mydomain.com/#aboutus mydomain.com/#register What's the best library that can handle all of this? I recently looked at 3 different plugins - jquery history plugin , history , and jQuery BBQ . They were all quite hard to setup, I did get jQuery.history working but it still had problems with IE7. So I changed to

changing location.hash with jquery ui tabs

安稳与你 提交于 2019-11-27 11:33:08
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. Thanks. Edit: It looks like part of my initial problem had something to do with js somewhere else

Keeping history of hash/anchor changes in JavaScript

微笑、不失礼 提交于 2019-11-27 10:34:35
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 methods are there to keep track of the history? I've implemented functionality that has been tested to

Encoding of window.location.hash

 ̄綄美尐妖づ 提交于 2019-11-27 10:07:49
问题 Does window.location.hash contain the encoded or decoded representation of the url part? When I open the same url ( http://localhost/something/#%C3%BC where %C3%BC translates to ü ) in Firefox 3.5 and Internet Explorer 8, I get different values for document.location.hash : IE8: #%C3%BC FF3.5: #ü Is there a way to get one variant in both browsers? 回答1: Unfortunately, this is a bug in Firefox as it decodes location.hash an extra time when it is accessed. For example, try this in Firefox:

ASP.Net MVC RedirectToAction with anchor

吃可爱长大的小学妹 提交于 2019-11-27 06:15:47
I have the following problem: For example I have route like this: routes.Add(new Route("forums/thread/{threadOid}/last", new MvcRouteHandler()) Defaults = new RouteValueDictionary( new { controller = "Thread", action ="ShowThreadLastPostPage"}), Constraints = new RouteValueDictionary(new { threadOid = @"^\d+$" }) } ); Is there a way using RedirectToAction method navigate to the URL like this: forums/thread/{threadOid}/last#postOid I think you should use the Redirect method along with Url.RouteUrl to accomplish it. return Redirect(Url.RouteUrl(new { controller = "Thread", action =

How to get the URL fragment identifier from HttpServletRequest

99封情书 提交于 2019-11-27 05:07:15
How do I get the URL fragment identifier from HttpServletRequest ? The javadocs doesn't seem to mention it. You can't get the URL fragment in the way you'd like. Typically, the browser doesn't send the fragment to the server. This can be verified by using a network protocol analyser like tcpdump, Ethereal , Wireshark , Charles . However, you can send the fragment string as a GET/POST parameter on a JavaScript request. To get the value using JavaScript, use window.location.hash . You can then pass this value as a GET or POST parameter in an AJAX request, and use the getParameter methods on the