hashchange

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

旧时模样 提交于 2019-12-05 21:41:49
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 Home Profile Message Setting This is Home As the code says my Div contents updated when i click any of

jQuery LocalScroll + hashchange event browser compatibility issue

主宰稳场 提交于 2019-12-04 21:24:14
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 people who were looking to do something similar. I ended up using Ben Almans jQuery hashchange event

Does onHashChange work in Safari?

六眼飞鱼酱① 提交于 2019-12-04 09:53:08
Does onHashChange or hashChange work in Safari? I tested it with Safari 4.0.4 on Windows 7 and it doesn't work for me. If it doesn't work, is there any solution to track if the hash has changed? In our app we poll to check for changes: $b.hashCheck = setInterval( function(){ if ( window.location.hash !== $b.C.current_hash){ $b.C.current_hash = window.location.hash; //call the on change action here } },$b.C.hashCheckDelay ); $b is the global object we use for our namespace and hashCheckDelay was empirically set at 120ms. While it looks a bit sad to do this kind of process, there isn't any

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

北城余情 提交于 2019-12-04 09:26:26
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 meantime the user will often not wait for them to load fully and click the "Page One" link. This clears

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

◇◆丶佛笑我妖孽 提交于 2019-12-04 02:41:53
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? Looks like this has been solved in a current commit to jquery mobile UI. https://github.com/jquery/jquery-mobile/commit

JavaScript .hashchange performance. Can it bring any slowdown?

非 Y 不嫁゛ 提交于 2019-12-03 16:22:44
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 in which cases? Checking a simple string property every 50ms is an infinitesimal cost compared to

How to “bookmark” page or content fetched using AJAX?

天涯浪子 提交于 2019-12-03 14:35:59
问题 How to "bookmark" page or content fetched using AJAX? It looks like it can be easy if we just add the details to the "anchor", and then, use the routing or even in PHP code or Ruby on Rails's route.rb, to catch that part, and then show the content or page accordingly? (show the whole page or partial content) Then it can be very simple? It looks like that's how facebook does it. What are other good ways to do it? 回答1: Update: There is now the HTML5 History API (pushState, popState) which

Get the hashchange event to work in all browsers (including IE7)

☆樱花仙子☆ 提交于 2019-12-03 03:13:34
问题 I have some code (written by another developer) that is doing AJAX page loading inside of WordPress (e.g. no page reloads) when you click a nav item, AJAX refreshes the primary content area. My problem is that it's broken in IE7 and I have no idea where to start in terms of debugging. The original opening lines were var queue = 0; $('document').ready(function() { window.addEventListener("hashchange", hashChange, false); // Define window location variables var windowHost = window.location.host

hashchange前端页面跳转

醉酒当歌 提交于 2019-12-03 02:49:22
现在有许多网站支持SPI(single page interface),和传统的MPI(multi page interface)比起来,它无需载入新的网页,速度会快很多,用户体验也会好很多。唯一的问题是如果你的页面改动很大,比如切换tab,页面大部分内容由ajax载入。用户会以为跳转到另一个页面,这时如果他们点击后退按钮,SPI就会出问题了,因为我们只有一个页面。 解决办法就是使用hashchange事件。一方面是当你切换tab时,在url里加入hash,javascript里是location.hash;另一方面是当hash变化是捕捉到该事件,大部分新的浏览器支持onhashchange事件。 至于IE6,7,我们需要用iframe去模拟这两个方面。 这里推荐一个jquery plugin: http://benalman.com/projects/jquery-hashchange-plugin/ 我的一个例子: //include jquery plugin var prefix = 'hash-'; // Bind the event. $(window).hashchange( function(){ var hash = window.location.hash.replace( /^[^#]*#?(.*)$/, '$1' ); if((hash == (prefix

Get the hashchange event to work in all browsers (including IE7)

谁说胖子不能爱 提交于 2019-12-02 15:17:14
I have some code (written by another developer) that is doing AJAX page loading inside of WordPress (e.g. no page reloads) when you click a nav item, AJAX refreshes the primary content area. My problem is that it's broken in IE7 and I have no idea where to start in terms of debugging. The original opening lines were var queue = 0; $('document').ready(function() { window.addEventListener("hashchange", hashChange, false); // Define window location variables var windowHost = window.location.host, windowHash = window.location.hash, windowPath = window.location.pathname; But I changed them to make