ReplaceState history no longer works in Chrome for local file

I use window.history.replaceState () to change the query string of the HTML file that was accessed using the file: /// C: / ...

This worked in Chrome, Internet Explorer and FireFox, but no longer works in Chrome. Not sure when it stops working. I have Chrome 45.0.2454.85. It still works in other browsers.

I get:

Uncaught SecurityError: Failed to execute 'replaceState' in 'History': History state object with URL 'file: /// C: /Users/Michael/Desktop/test.html? Q = NewQueryString 'cannot be created in a document with the original value "null".

Sorry, but this does not work in any hosting. You can copy the code to a local HTML file to see it for yourself:

<html> <body> <button onclick="clickme()">Click me</button> <script> function clickme() { window.history.replaceState({ "html": undefined, "pageTitle": "NewTitle"}, "", "?Q=NewQueryString"); } </script> </body> </html> 

Obviously, I could host this on the server, but tried to stay simple. This is a simple scripting board that we use as Git. He uses a third-party web service to retrieve data. Any ideas for working with the error.

+7
javascript google-chrome
source share
2 answers

He stopped working with Chrome 45. Here I filled out a question about code.google: https://code.google.com/p/chromium/issues/detail?id=529313

Setting -allow-file-access-from-files is a good solution if you just need to run it on your own computer.

+4
source share

I had the same problem. As a workaround, I started using Chrome with the -allow-file-access-from-files checkbox.

But think that this is not the best solution.

Below is an example of how I run:

"C: \ Program Files (x86) \ Google \ Chrome \ Application \ chrome.exe" --app = file: /// C: /APP/index.html --allow-file-access-from- files

If someone finds a better solution, let us know.

+3
source share

All Articles