pushstate

Detect whether HTML5 History supported or not

纵饮孤独 提交于 2019-12-03 08:10:44
问题 How can I check if the browser you are using supports the HTML5 history api? As you can see here http://caniuse.com/#search=history only chrome +ff4 and several others supports this and I wish to do something else if they cant support this. How can I make some kind of an if statement for this checking? 回答1: if (window.history && window.history.pushState) See also this All-In-One Almost-Alphabetical No-Bullshit Guide to Detecting Everything 回答2: You can detect support for history management

How to update the twitter share button URL with dynamic content?

送分小仙女□ 提交于 2019-12-03 06:25:12
问题 I initialize the tweet button at the beginning of my app, after user interaction the current window's location is updated using HTML5 pushState, but the twitter button is still sharing the previous URL from when it was initialized. How do I update the URL that twitter uses? 回答1: I figured this out. Here's how to make this work. The general idea is: In your HTML set the class of your <a> for the twitter share button to be something other than .twitter-share-button . Also give the <a> a style=

IE not firing popstate when hashchange happens

断了今生、忘了曾经 提交于 2019-12-03 06:21:47
I have page that is doing the routing on clientside, using history API & push/popstate. Which works just fine on all the modern browsers. (search engines will be supported by node.js prerenderer) However, I recently bumped into issue where IE doesn't fire popstate on hashchange while, while pushstate with urls works just fine, including IE11. For example, like so... $(document).on('click', 'a', function(e) { e.preventDefault(); History.pushState({}, '', $(this).attr('href')); }); ...which correctly fires... $(window).on('popstate', function() { console.log('url changed'); }); According the W3C

Moving back to a pushState entry that used ajax

喜你入骨 提交于 2019-12-03 05:06:58
问题 I'm having an issue with the following situation. User visits site User clicks link which uses history.pushState to update the url Partial page content loaded via ajax (using jQuery) User clicks regular link which loads a new page User clicks back to return to the pushState entry The page now displays only the page partial that was retrieved via ajax I've souped up a site using pushState for various things and the result is a shockingly responsive web app, but this issue is preventing me from

HTML5 pushstate and SEO link

倾然丶 夕夏残阳落幕 提交于 2019-12-03 04:05:50
I try to implement pushstate history on my website in order to load content from a single.php page inside a index.php container. My website have two main page : index.php and single.php . On the index.php there are links that call pushstate script: <a class="phplink" href="/Formlabs-3D-printer" title="Formlabs 3D printer">Post 12</a> <a class="phplink" href="/Minimal-Bumper-for-iPhone-5" title="Minimal Bumper for iPhone 5">Post 11</a> On my single.php page I use isset get method to dynamically load content that correspond to clicked link on index.php: <?php if (isset($_GET["page"])) { //I do

history.pushState - not working?

不羁岁月 提交于 2019-12-03 01:57:28
I want to change html without reload. I do it like: $('#left_menu_item').click(function(e) { if (!!(window.history && history.pushState)) { e.preventDefault(); history.pushState(null, null, newUrl); } }); It works correctly. But if I want to go back with "Back" button - browser change url on previous, but it not reload page. Why? this behaviour is expected and is in accordance with the specifications of manipulating the history stack. this is a relatively complex problem to explain. but in short think of it as this: any history entry the user pushes on the history stack (using pushState etc)

preserving browser “back” button functionality using AJAX/jQuery to load pages and history.pushState() method

对着背影说爱祢 提交于 2019-12-02 23:32:09
I'd like to preserve the back button functionality when loading pages via AJAX (jQuery load method) and pushing the URL to the browser bar via the history.pushState method. The problem occurs when one clicks on the browser back button and the 1st click only restores the previous URL but does not load the previous page. Here's my code so far: $(function(){ var profile_url= "/profile"; $('#click_button').click(function(){ $('#main_content').load(profile_url); history.pushState({profile:profile_info}, "profile", profile_url); }); }); My question is is there any way to do an AJAX load of the

HTML5 History API - What is the max size the state object can be?

徘徊边缘 提交于 2019-12-02 23:06:36
The pushState method accepts a state object. Firefox documents say the maximum size of this object is 640kb. Is it defined in the specs what the smallest maximum size a browser can implement is? Can I reasonably expect major browsers to provide me with at least 100kb? EDIT: I tested it out with Chrome, and it was still working for state objects over 1MB. No. The normative document here is http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html#dom-history-pushstate and it doesn't even mention a limit for the data size. A different limit is suggested however: User agents may

back button in browser not working properly after using pushState (in Chrome)

非 Y 不嫁゛ 提交于 2019-12-02 22:04:42
I am using this type of line in an JS response if (history && history.pushState){ history.pushState(null, null, '<%=j home_path %>'); } but when I click back in the browser, I see the JS code of the response instead of the previous page. Is there a way to make the back button work so it would re-request the page of the last url (before home_path as pushStated in? Update : I've found this .. it seems other have the same issue with.. History.js doesn't fix it either So to confirm some of the comments there.. This happens only in chrome What I think I think the root of all this is that the

Detect whether HTML5 History supported or not

被刻印的时光 ゝ 提交于 2019-12-02 21:47:37
How can I check if the browser you are using supports the HTML5 history api? As you can see here http://caniuse.com/#search=history only chrome +ff4 and several others supports this and I wish to do something else if they cant support this. How can I make some kind of an if statement for this checking? Gaurav if (window.history && window.history.pushState) See also this All-In-One Almost-Alphabetical No-Bullshit Guide to Detecting Everything You can detect support for history management (as well as many other browser features) using Modernizr . if (Modernizr.history) You can use canisuse.js