hashchange

Is it possible to capture the window.location.replace event?

纵然是瞬间 提交于 2019-12-10 19:51:37
问题 If I'm currently at the URL "example.com/somepage#somehash" and I invoke window.location.hash = "anotherhash" , the URL changes to "example.com/somepage#anotherhash" . This fires the window.hashashchange event. If I am currently at the URL "example.com/somepage?a=1&b=two" and I invoke window.location.replace("?one=1&two=2") , then the URL changes to "example.com/somepage?one=1&two=2" . I've read the MDN docs, and I can't find an even that this fires. Is there one? If not, is there a simple

DOMNodeInserted or hashchange

蓝咒 提交于 2019-12-10 15:35:52
问题 I am trying to write a JavaScript script that is "overlayed" on top of a Facebook page. It uses DOMContentLoaded to detect when content is loaded, then adds some extra stuff in. However, because Facebook doesn't actually "reload" the page when going to a new page (it just uses AJAX), the DOMContentLoaded handler doesn't run again, even though there is new stuff to look through. Anyway, to detect the change, I thought about using onhashchange since Facebook used to change the page's hash, but

JavaScript .hashchange performance. Can it bring any slowdown?

匆匆过客 提交于 2019-12-09 13:26:30
问题 jQuery hashchange event For me it looks like most mature solution right now(please correct me if I'm wrong). I really like this plugin for manipulating with browsers hashes. It simplifies js code a lot in some cases. I really want to start use it extensively but I have a question for you. Accordingly to the source it uses loop and check whether hash anchor was changed every 50 ms. What about performance? Can I overuse hashchange? Can it lead to some significant slowdown in performance? If so

How to run a JavaScript function when the user is visiting an hash link (#something) using JQuery?

左心房为你撑大大i 提交于 2019-12-08 01:30:26
I have a webb application at http://example.com/app and I would like to show a form if the user is visiting http://example/app#add-item . Is there any way I can use a jQuery script to add this functionallity? My current jQuery script already has a structure like this: $(document).ready( function() { $('#search').keyup( function() { ... } ); } ) How can I show a form using someting like this: $(document).ready( function() { $('#search').keyup( function() { ... } ); $('#add-item').visit( // .visit probably doesn't exist function() { content.innerHTML = myForm; } ); } ) Here is something I do:

jQuery when pointed to a link should show a div that's hidden by default

旧街凉风 提交于 2019-12-07 19:29:50
问题 I have a page where there are a few divs hidden by default. I would like to be able to point users to a link where it would show the divs. ex. https://app.emailsmsmarketing.com/login Users are able to click "Register" which hides the login div and shows the register div. What I'm trying to accomplish is basically adding a link to the main site from where users will be able to access the registration form by default (using jQuery only). ex. https://app.emailsmsmarketing.com/login#!register (or

I need to update my page using Anchor (#) in URL

白昼怎懂夜的黑 提交于 2019-12-07 17:12:06
问题 index.php <html> <head> <title>My Title</title> <script type="text/javascript"> function getLink(data) { document.getElementById("box").innerHTML="This is "+data; } </script> </head> <body> <a href="#home" onClick="getLink('Home')">Home</a><br /> <a href="#profile" onClick="getLink('Profile')">Profile</a><br /> <a href="#message" onClick="getLink('Message')">Message</a><br /> <a href="#setting" onClick="getLink('Setting')">Setting</a><br /> <hr /> <div id="box"></div> </body> </html> Output

jQuery LocalScroll + hashchange event browser compatibility issue

坚强是说给别人听的谎言 提交于 2019-12-06 15:54:55
问题 I'm building a site where I am using Ariel Fleslers jQuery LocalScroll plugin, which I want to do two things: 1) Animate a scroll to an anchor when a link is clicked 2) Scroll to the previously visited anchor when the browsers' back button is pressed. The scrolling takes place inside a container where the content is overflowing. Number one was straight forward enough. To acheive number two I did a fair bit of googling but didn't really find a solution, even though I came across a few posts by

Javascript/jQuery detect hash change only on browser back/forward button click

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 02:57:53
问题 Is it possible to detect the hashchange only on a browser history change (i.e. Back or Forward button)? I have seen the onBeforeUnload event, but this event does not fire on hash change, as the window is not unloading. The hashchange event obviously fires anytime the hash changes. Any fix? Preferably without a plugin. I have seen the jQuery history plugin, but am looking for the simplest solution. Thanks for the help. 回答1: Take a look at the window.onhashchange event. It is not currently

Stop loading of images on a hashchange event via JavaScript or jQuery

大憨熊 提交于 2019-12-06 02:47:50
问题 I am using the jQuery BBQ: Back Button & Query Library plugin to create a page that pulls in dynamic content when a link is clicked. When the link is clicked the hash is changed and new content is pulled in (the 'default' action of clicking a href is therefore disabled.) That part works just fine, but there is a problem. Example of my problem Say the "home" page has a DIV a number of images in it and a list of links ... Page One Page Two Page Three The images may take a while to load, in the

Disable the hash change controller in JQuery mobile UI and replace with backbone.js

拜拜、爱过 提交于 2019-12-05 21:54:35
问题 I'm using JQuery Mobile UI and the widgit kit is nice. However I'm also using backbone.js which comes with a really neat hashchange controller framework. Problem is that JQuery Mobile UI has an inbuilt crappy hash change controller which assumes you willl always want to make an AJAX query on every hash change and load the content from the server. Has anybody had any success in just pulling out the widget framework from JQuery Mobile UI? 回答1: Looks like this has been solved in a current commit