html5-history

Angular route with html5Mode giving 'Not found' page after reload

心不动则不痛 提交于 2019-11-30 07:36:34
I made some Angular routes as shown in the code bellow. app.config(function($routeProvider, $locationProvider, $provide) { $routeProvider .when('/', { templateUrl: 'home.html', controller: 'AppCtrl' }); .when('/portfolio', { templateUrl: 'portfolio.html', controller: 'AppCtrl' }) $provide.decorator('$sniffer', function($delegate) { $delegate.history = historyCompatCheck(); return $delegate; }); $locationProvider.html5Mode(true); }); This works fine, after i set the base href to be "/" it accepted an anchor with the href of "/portfolio", but when i go to " http://url.com/portfiolo " or try to

Appending parameter to URL without refresh

若如初见. 提交于 2019-11-30 00:05:04
I know this has been asked many times before but answers were not descriptive enough to solve my problem. I don't want to change the whole URL of page. I want to append a parameter &item=brand on button click without refresh. Using document.location.search += '&item=brand'; makes the page refresh. Using window.location.hash = "&item=brand"; append without refresh but with a hash # which eliminates the usage/effect of the parameter. I tried to remove the hash after appending but that didn't work. This answer and many others suggest the use of HTML5 History API, specifically the history

jQuery bind popstate event not passed

笑着哭i 提交于 2019-11-29 16:09:10
问题 I'm coding a little demo for the History API. And I'm struggling with this: $(window).bind('popstate', function(event) { console.log('pop: ' + event.state); }); It logs 'pop: undefined' when I click on the 'Previous' button... But if I do this instead, things are working like expected : window.onpopstate = function(event) { console.log('pop: ' + event.state); }; It logs 'pop: [object Object]' this time... So it's like jQuery doesn't pass the event object to the callback. Is there a problem

Title of history.pushState is unsupported, what's a good alternative?

断了今生、忘了曾经 提交于 2019-11-29 03:37:39
The second parameter of History.pushState and History.replaceState can be used to set the "title" of the history entry. This means that when the user clicks through page 1 to page 8, this is what he should see in his history bar: And it is working on Safari and Opera. But on Chrome and FireFox, this is what the user sees: Trying to change document.title doesn't work as it changes all the entries within the history title: What's the best solution to this problem? Are we forced to using only one history title for all the pages implemented using pushState and replaceState ? I had the same problem

HTML5 History API Demo

こ雲淡風輕ζ 提交于 2019-11-29 00:39:21
I've been reading about the HTML5 history API and so far, I haven't found a simple working demo that shows the mechanics with code. Here is a working jsfiddle : 4 buttons and 4 divs. When the user presses a button, it shows the corresponding panel. What I'm looking to do is: 1) rewrite the URL so that when the user is on panel 4 the url ends with /Panel4 2) make the back button and forward button work with the history API. I know there's the history.js plug-in but I want to understand how the API works in its simplest form. Hopefully, the jsfiddle will help others who'll come to this page

History API: Javascript Pushstate, get previous URL

安稳与你 提交于 2019-11-28 04:34:30
问题 $(window).bind('statechange',function(){ var State = History.getState(), url = State.url; }); In the following function, url returns the current URL. What I'm looking for is, within that function, to get the previous URL, so for example, if I'm on /cars/ferrari and go to /cars/ford , url would return cars/ford , but I want to get /cars/ferrari . How do I get the previous URL within a statechange event? 回答1: $(window).bind('statechange',function(){ // Prepare Variables var State = History

How do I use window.history in JavaScript?

流过昼夜 提交于 2019-11-28 01:57:15
I found a lot of questions about this on Stack Overflow, but they were all very specific about certain parts. I did find this question whose answers provide some nice references, but they don't actually explain how it all works, and their examples hardly do anything. I want to know more about how it all works together, and I want to use vanilla JavaScript. (Also, many of the answers on other questions are years old.) GETTING STARTED First of all, you can remove the window part. Just history works fine. But before we get into how everything works together, we need to know what we can use.

Title of history.pushState is unsupported, what's a good alternative?

风流意气都作罢 提交于 2019-11-27 22:10:19
问题 The second parameter of History.pushState and History.replaceState can be used to set the "title" of the history entry. This means that when the user clicks through page 1 to page 8, this is what he should see in his history bar: And it is working on Safari and Opera. But on Chrome and FireFox, this is what the user sees: Trying to change document.title doesn't work as it changes all the entries within the history title: What's the best solution to this problem? Are we forced to using only

Appending parameter to URL without refresh

社会主义新天地 提交于 2019-11-27 20:20:02
问题 I know this has been asked many times before but answers were not descriptive enough to solve my problem. I don't want to change the whole URL of page. I want to append a parameter &item=brand on button click without refresh. Using document.location.search += '&item=brand'; makes the page refresh. Using window.location.hash = "&item=brand"; append without refresh but with a hash # which eliminates the usage/effect of the parameter. I tried to remove the hash after appending but that didn't

HTML5 History API Demo

爱⌒轻易说出口 提交于 2019-11-27 15:24:16
问题 I've been reading about the HTML5 history API and so far, I haven't found a simple working demo that shows the mechanics with code. Here is a working jsfiddle: 4 buttons and 4 divs. When the user presses a button, it shows the corresponding panel. What I'm looking to do is: 1) rewrite the URL so that when the user is on panel 4 the url ends with /Panel4 2) make the back button and forward button work with the history API. I know there's the history.js plug-in but I want to understand how the