pushstate

history.pushState does not update url for “share …” button on mobile Chrome

岁酱吖の 提交于 2019-12-06 03:29:28
I am using history.pushState to update URL as below: var state = {url: newLocation}; window.history.pushState(state, pagetitle, newLocation); On Mobile Chrome, the webpage URL (on the URL bar) and title do get updated as expected. But when clicking on the "Share..." button on the Chrome menu, the old URL (before calling history.pushState) is shared instead. Am I missing anything and how can I fix it? Thanks! I found out that the rel="canonical" url should also be updated. $('link[rel="canonical"]').attr('href', newLocation); 来源: https://stackoverflow.com/questions/51518379/history-pushstate

history.pushState disappears in IE 11

淺唱寂寞╮ 提交于 2019-12-05 19:09:00
There is a site http://www.pionart.pl which is a good illustration of the problem I have with the current site I develop with almost the same code/CMS When I enter the site with IE 11, the browser forgets half of the history methods, incl. history.pushState() (you can easily check it by invoking the console with F12 and typing history.) When I enter http://stackoverflow.com in the same tab, IE suddenly remembers all the methods back. The question: what is the purpose of the "forgetting"? How to prevent it? Adam The problem was <meta http-equiv="X-UA-Compatible" content="IE=9"> It forced IE 11

is Pushstate inferior to Hashbangs when it comes to caching?

时光怂恿深爱的人放手 提交于 2019-12-05 16:01:01
There are several advantages to the HTML5 Pushstate in comparison to hasbangs, in fact, Google is now encouraging the use of Pushstate . The only Pushstate disadvantage being publicly discussed is the fact that non-modern browsers do not support it. However, to me it seems that Pushstate is also disadvantageous when it comes to caching. I might be wrong, hence this question. is Pushstate inferior to Hashbangs when it comes to caching pages? Here is a case where it seems that Pushstate is bad at caching. Pushsate Bob navigates to eg.com/page1 , the full page is downloaded, rendered and cached.

history.pushState in Chrome make favicon request

孤街浪徒 提交于 2019-12-05 14:04:36
问题 code : var newurl = window.location.protocol + "//" + window.location.host + window.location.pathname +"?"+ queryStr; window.history.pushState({path:newurl},'',newurl) current scenario : everytime when window.history.pushState() is invoked favicon requests occur rapidly.It makes network request for favicon on every call of this function. expected scenario : favicon should be loaded only once on page load, I would not expect the favicon load on every request of window.history.pushState() .

hashchange firing popstate

 ̄綄美尐妖づ 提交于 2019-12-05 12:38:33
问题 Here's what I'm working with Code: <a href="#" onclick="window.onpopstate = function() { alert('pop'); }; return false; ">set up window.onpopstate </a><br> <a href="#somehash2">change hash</a> <div onclick="alert(location.href);">show location.href</div>​ Why does clicking the change hash link fire the popstate, shouldn't it only be fired if I click the change hash link then click back? 回答1: The reason window.onpopstate fires are not because of a change to the hash. It's because the history

history pushState and scroll position

大城市里の小女人 提交于 2019-12-05 12:00:30
问题 I am trying to retrieve the scroll position when a user navigates back in the browser history using HTML5 popstate handler. Here is what I have: $(document).ready(function () { $(window).on('popstate', PopStateHandler); $('#link').click(function (e) { var stateData = { path: window.location.href, scrollTop: $(window).scrollTop() }; window.history.pushState(stateData, 'title', 'page2.html'); e.preventDefault(); }); }); function PopStateHandler(e) { alert('pop state fired'); var stateData = e

Backbone.js change url without reloading the page

百般思念 提交于 2019-12-05 04:25:53
I have a site that has a user page. On that page, there are several links that let you explore the user's profile. I'd like to make it so that, when one of those links is clicked on, the url changes, but the top third of the page containing the user's banner doesn't reload. I'm using Backbone.js I have a feeling that I'm in one of those situation where I have such a poor understanding of the problem I'm dealing with that I'm asking the wrong question, so please let me know if that appears to be the case Peter Berg My mistake was assuming that there was a special, built-in way of doing this in

Check if user logged in on ajax page change

心不动则不痛 提交于 2019-12-04 15:11:11
As part of a webapp I'm building I'll need to check if the user is logged in whenever they change page. On a normal non-ajax site this is easy because I can just place the PHP session conditional statement in the header, and the header being called on every page change will determine whether the login page is displayed or not, but seeing as the header file is only set once within an ajax application, which is on the initial load, how can I check whenever the user makes an ajax page request whether or not the session is still valid? Since I'm using pushState and popState I know I can set the

Html4 browsers does not support history.pushState and history.replaceState methods of History API from HTML5

旧时模样 提交于 2019-12-04 13:28:23
问题 I am working on an ember application (using ember-1.0.pre.js). And I'm trying to provide cross browser compatibility on IE8. The issue is with url generate after every transition, it seems incorrect/falsy to user. Let say I hit the url like the_ domain_name/sell/new which initially land me to on sell page of our application. and then i tries to transit a new state called "Purchase" which will land me on purchase page of our application. The new state transition generates a URL the_ domain

IE not firing popstate when hashchange happens

半世苍凉 提交于 2019-12-04 10:36:43
问题 I have page that is doing the routing on clientside, using history API & push/popstate. Which works just fine on all the modern browsers. (search engines will be supported by node.js prerenderer) However, I recently bumped into issue where IE doesn't fire popstate on hashchange while, while pushstate with urls works just fine, including IE11. For example, like so... $(document).on('click', 'a', function(e) { e.preventDefault(); History.pushState({}, '', $(this).attr('href')); }); ...which