browser-history

How can I prevent the browser to scroll to the top on hash change?

≡放荡痞女 提交于 2019-12-13 21:22:44
问题 I am building a web application where I need to prevent back navigation in the browser history. After searching the threads in StackOverflow I found this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <title>Untitled Page</title> <script type = "text/javascript" > function changeHashOnLoad() { window.location.href += "#"; setTimeout("changeHashAgain()", "50"); } function

How to recognize if the route was initiated through a history.push or a manual adress change (react-router)

两盒软妹~` 提交于 2019-12-13 20:06:34
问题 I have the browser cache as the central single source of truth. When I want to change the app state, I just change the broser cache and call setState to trigger a render(). Everything works fine unless the user changes the adress manually (refreshes the window, clicks on a bookmark, etc...), to fix that, I made the router's render method ( <Router render={render}> ) save the url's params myUrl/:myVar1/:myVar2 in the browser cache too My issue is that I don't want the router to ovveride what

HTML mini browser back button disabling

走远了吗. 提交于 2019-12-13 15:58:46
问题 i have the following webpage: <!Doctype html> <html> <head> <script> function display(value){ document.getElementById('displayer').src=value; return false; } </script> </head> <body> <form name="x" onsubmit="return display(this.y.value)"> <input name="y" /><input type="submit" value="display"/> </form> <iframe id="displayer">ERROR</iframe> <button onclick="document.getElementById('displayer').contentWindow.history.back()">Click me to go back in the history of iframe!</button> </body> </html>

Accessing a user's history using JS

戏子无情 提交于 2019-12-13 13:39:51
问题 I'm not looking for code/how to. Just knowledge. A client has just come to us with a question: Can we access the user's history from within a banner advert to give them some targeted advertising based on their history. Obviously, this presents a privacy issue , but I need to give a good case for why it is technically not a viable option. So I have a few questions... Which browsers still , if any, support accessing a user's history, using window.history . If some do and some don't. When did

Cannot delete URLs with Chrome's history API

為{幸葍}努か 提交于 2019-12-13 06:13:36
问题 I am making a Chrome extension to remove certain URLs from my history, using Chrome's history API. Here is the code so far: document.addEventListener('DOMContentLoaded', function() { var form = document.getElementById('form'), query = document.getElementById('query') form.onsubmit = function(e) { e.preventDefault() // alert(chrome.history) // [object Object] // alert(chrome.history.deleteUrl) // function () { [native code] } // alert(query.value) // whatever I typed chrome.history.deleteUrl

Moving back webpages with Javascript

限于喜欢 提交于 2019-12-13 04:45:37
问题 Ok this is the issue. I am working in a popup. We go from Page 1 to Page 2. Page 2 has frames set up on it. I know it's bad but it was not my decisions. Now on Page 2 in one frame we continue onto Page 3. If I click the back button on Page 2 with javascript history.go(-1) we can get to Page 1. But if the user goes from Page 2 to Page 3 then back to Page 2 a user can not simple go back to Page 1 unless the javascript is history.go(-3). Is there a way I can tell where I am coming from so I can

Finding previous URL from window.history

核能气质少年 提交于 2019-12-13 00:46:13
问题 I've hosts file blocking so time to time, I get these "Page not found" errors browsing thru deals. Since I got tired of copying the target url, unescaping, replacing it in address bar and hitting enter, I wrote a handy bookmarklet to automate this: (function () { var href = window.location.href; var loc = href.indexOf('url='); if (loc > 0) { var endLoc = href.indexOf('&', loc + 4); endLoc = endLoc > 0 ? endLoc : href.length; window.location.href = unescape(href.substring(loc + 4, endLoc)); }

Why is javascript:history.go(-1); not working on mobile devices?

岁酱吖の 提交于 2019-12-12 16:09:05
问题 First, some background: I have an application which presents a search page (html form) to the user. Once criteria have been filled out and the Search button is clicked, results appear beneath the criteria section. In the list of results, you can view the detail of an individual result by clicking a link which takes you to a new page. Within the detail page, I have included a Back to Results link like so: <a href="#" onclick="history.go(-1);return false">Back to Results</a> This works great in

Unit testing react actions - browserHistory is undefined

北慕城南 提交于 2019-12-12 11:05:12
问题 I writing tests for my actions, that using { browserHistory } from 'react-router'; And when i'm running my tests, imported browserHistory is undefined for unknown reasons. Therefore, test throws an error - "Cannot read property 'push' of undefined"; I don't know, why browserHistory is undefined, if it works in my app. Can somebody help me? 回答1: I will guess you are not using karma or any browser to run your test. The object browserHistory will be undefined if there is not a browser. You may

History API html5, how to know when user clicked in next/back browser buttons? [duplicate]

▼魔方 西西 提交于 2019-12-12 08:39:36
问题 This question already has answers here : Is there a way to tell what direction the state is going with history.js? (2 answers) Closed 6 years ago . I am getting familiar with the html5 History API, but I am using history.js to extend the compatibility, I have one question and it's that, how can I know in: History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate var State = History.getState(); // Note: We are using History.getState() instead