browser-history

Alert, confirm, and prompt not working after using History API on Safari, iOS

一个人想着一个人 提交于 2019-11-30 02:58:36
After calling history.pushState in Safari on iOS, it's no longer possible to use alert() , confirm() or prompt() , when using the browser back button to change back. Is this an iOS bug? Are there any known workarounds? Simple example to reproduce this behavior: <html> <body> <ul> <li>Step 1: <button onclick="alert(Math.random())">Confirm Alert is working</button></li> <li>Step 2: <button onclick="history.pushState(null, null, '/debug/'+Math.random());">Change History</button></li> <li>Step 3: use your browser back button, to go back</li> <li>Step 4: <button onclick="alert(Math.random())">Alert

Add to browser history without page reload

我怕爱的太早我们不能终老 提交于 2019-11-30 00:46:03
问题 Basically, I have a page that contains a form. When a user submits that form, a Javscript function is called and the user is dynamically presented with a new form. At this point, what I would like is for the user to be able to click the browser's back button and be taken back to the first form. Is this possible? Thanks for the quick responses, but I am having trouble getting pushState to work. The HTML still displays "second form" after I click the back button. Here is the code I used to test

How to implement my own history stack in a single page mobile web application?

只愿长相守 提交于 2019-11-30 00:09:14
I have a single-page mobile application developed with Backbone and Zepto. It works correctly with the back/forward buttons in the browser. When the user navigates to a page, the new content slides in from the right as the old contents slides away to the left (and out of the viewport). I want the same thing to happen if the user presses the "forward" browser button. This all works. I've got a class that I add to the body element navigate-back that will flip this behaviour, so when the user navigates back with the browser's back button, they see the content sliding back in from the left and the

Does back/forward in the browser change javascript variables?

心已入冬 提交于 2019-11-29 22:26:35
问题 <script type="text/javascript> var x = 0; //this occurs in the beginning of the page. $("#button").onclick{ x = 1; } </script> Let's say the variable "x" changes to 1. Then the user clicks a link. When the user clicks "back", will x be 0 or 1? 回答1: It will be 0 . The browser does not cache the state of Javascript variables between page loads. Update This is not the case in browsers such as Firefox. Please see Trey's answer. 回答2: As detailed in another question, the real answer to this

onclick=“javascript:history.go(-1)” not working in Chrome

孤街醉人 提交于 2019-11-29 20:43:52
This code works fine in FF, it takes the user back to the previous page, but not in Chrome: <a href="www.mypage.com" onclick="javascript:history.go(-1)"> Link </a> What's the fix? Mohit Padalia You should use window.history and return a false so that the href is not navigated by the browser ( the default behavior ). <a href="www.mypage.com" onclick="window.history.go(-1); return false;"> Link </a> Majid Ali Khan Use the below one, it's way better than the history.go(-1) . <a href="#" onclick="location.href = document.referrer; return false;"> Go TO Previous Page</a> Why not get rid of the

Is this a proper way to use History.js?

自作多情 提交于 2019-11-29 20:20:58
I was able to put together a simplified complete History.js example using three links to load fragments of content from a full page without updating the page and while updating the browser history. Here are the relevent code snippets - a complete working example is here http://jsfiddle.net/PT7qx/show <a href="/page-header">Page Header</a> <a href="/login-form">Login Form</a> <a href="/nothing">Nothing</a> <script> var History = window.History; if (!History.enabled) { return false; } History.Adapter.bind(window, 'statechange', function() { var State = History.getState(); History.log(State.data,

Cross-browser jquery ajax history with window.history.pushState and fallback

感情迁移 提交于 2019-11-29 20:08:18
I want to implement a navigation history using jQuery and AJAX in a cross-browser manner. My approach is to use window.history.pushState and fall back to a hash url /#!/url in browsers that do not support window.history.pushState . For example: <a href="/home">home</a> <a href="/about">about</a> <a href="/contact">contact</a> On browsers that support window.history.pushState , clicking on one of these links should change address without page refresh to http://domain.com/home , http://domain.com/about etc. When the browser does not support window.history.pushState , it should use a fragment

How do I actually use history.js on my site

和自甴很熟 提交于 2019-11-29 19:54:20
I've read all the posts about history.js on stackoverflow including, this , this and this and at looked the source code but as a newcomer to javascript/jquery I'm having trouble figuring out how to actually implement to have html 5 history support and fallback to support html4 browsers such as ie8/9. As I can appreciate the UX benefits from presenting consistent URL's as much as possible, how this solves deep linking and allows for bookmarking I want to implement but I get a bit lost when trying to actually use this on my site. After adding history.js script to my page The code to modify as I

Get last page visited

ぐ巨炮叔叔 提交于 2019-11-29 19:54:11
问题 I need to know if a person that comes to my website went from an another specific website. Example: User A visits www.youtube.com/myvideo and clicks on a link to my website. User B visits google, search my website and click the link. Results Message on my page: User A: Welcome! You already know how it works, register now! User B: Welcome! Please watch our video first at www.youtube.com/myvideo My question is: Is it possible to know the last url the user visited before entering my page? I

Prevent browser scroll on HTML5 History popstate

流过昼夜 提交于 2019-11-29 18:54:58
Is it possible to prevent the default behaviour of scrolling the document when a popstate event occurs? Our site uses jQuery animated scrolling and History.js, and state changes should scroll the user around to different areas of the page whether via pushstate or popstate. The trouble is the browser restores the scroll position of the previous state automatically when a popstate event occurs. I've tried using a container element set to 100% width and height of the document and scrolling the content inside that container. The problem with that I've found is it doesn't seem to be nearly as