popstate

In iOS 7 Safari, how do you differentiate popstate events via edge swipe vs. the back/fwd buttons?

馋奶兔 提交于 2019-12-03 06:16:25
In iOS 7 Safari there are now two ways to navigate back/forward -- using the traditional back/forward button arrows at the bottom or by swiping from the edge of the screen. I'm using an animation to transition between pages in my ajax app, but I don't want to fire that transition if users are navigating via the edge swipe, because that is an animation itself. However, the popstate event objects appear to be identical for both types of navigation -- is there any way to differentiate between these two types of user navigations so we can respond accordingly? UPDATE: I was able to use (what

HTML5 History API back button with partial page loads

*爱你&永不变心* 提交于 2019-12-01 03:14:51
To improve the performance/responsiveness of my website I have implemented a partial page load using AJAX, replaceState, pushState, and a popstate listener. I essentially store the central part of my page (HTML) as my state object in the history. When a link is clicked I request just the central bit of the page from the server (identifying these requests with a different Accept header) and replace it with javascript. On popstate I grab the previous central part and push it back into the dom. This mostly works fine, however I have found a particular issue which I am stuck on. It is a little

HTML5 History API back button with partial page loads

让人想犯罪 __ 提交于 2019-12-01 00:17:25
问题 To improve the performance/responsiveness of my website I have implemented a partial page load using AJAX, replaceState, pushState, and a popstate listener. I essentially store the central part of my page (HTML) as my state object in the history. When a link is clicked I request just the central bit of the page from the server (identifying these requests with a different Accept header) and replace it with javascript. On popstate I grab the previous central part and push it back into the dom.

Is it possible to e.preventDefault in window.onPopState?

僤鯓⒐⒋嵵緔 提交于 2019-11-30 22:30:57
问题 Im trying to stop the user from going back in my web app. For this I tried catching the window.onpopstate and added e.preventDefault to cancel the back button effect. But it doesnt seems to happen. window.addEventListener('popstate',function(e){ console.log(e); e.preventDefault(); }); Is it not possible to prevent the popstate event of browser? Or am I doing something wrong? 回答1: According to this documentation, the popstate event is not cancellable: Specification: HTML5 Interface:

pushState() and popState(): manipulating browsers' history

柔情痞子 提交于 2019-11-28 19:55:25
I am working on a small project in which I want to create an Ajax-style website. Content is loaded with jQuery's load() . As some of you know, the down side of this is that the URL does not change accordingly to the content that is displayed. To make this work you can use pushState() . Because this is not cross-browser supported, I used the plug-in history.js . This is working quite nicely, but the problem is that my back and forward buttons are not working as they should and I have no idea what I am doing wrong. The URL is changing correctly and the content is as well, but the title is not

Can I prevent history.popstate from triggering on initial page-load?

我只是一个虾纸丫 提交于 2019-11-27 06:30:37
I'm working on a site that serves content via AJAX. If you click an item in the menu, a content div gets updated with $.get response, nothing fancy. I'm implementing history.pushState to allow navigation with the browser's back/forward button. I have the following to load content on history navigation: $(function() { $(window).bind("popstate", function() { $.getScript(location.href); }); }); The problem is, when a page is loaded for the first time, this function does $.getScript so the page is loaded immediately again. The first time the page is loaded it renders the initial HTML view, then on

Can I prevent history.popstate from triggering on initial page-load?

余生颓废 提交于 2019-11-26 12:55:13
问题 I\'m working on a site that serves content via AJAX. If you click an item in the menu, a content div gets updated with $.get response, nothing fancy. I\'m implementing history.pushState to allow navigation with the browser\'s back/forward button. I have the following to load content on history navigation: $(function() { $(window).bind(\"popstate\", function() { $.getScript(location.href); }); }); The problem is, when a page is loaded for the first time, this function does $.getScript so the