html5-history

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

React Router: Query Param Match?

99封情书 提交于 2019-12-06 03:19:30
问题 According to the accepted answer to this question, React Router 4 doesn't match query parameters anymore. If I go from a URL matched by one of my <Route> s to the same URL with a different query string, the content doesn't seem to change. I believe this is because navigating between URLs that match the same <Route> doesn't change the content, but please correct me if I'm wrong. Given this, how do I use React Router for a set of URL's that need to differ only by query parameter? For example,

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

Should I use an iframe rather than ajax?

烂漫一生 提交于 2019-12-05 01:30:29
We're building a Drupal site with an audio player which should keep playing while you browse the page (something like soundcloud). Currently we're loading clicked <a> 's sites with ajax and inject the html into the page and use history.js to manipulate the location. There is a major downside though: Since a newly loaded page may have different css and js on it, we have to compare the current script, style and link elements to the ajax response text (ugly regex) and only add the new, yet non-existing elements. By doing so, loading another page wont delete/remove/undo once executed scripts. This

How to enable offline support when using HTML5 history api

不问归期 提交于 2019-12-04 22:02:23
What are the best practices (and how to go about doing it) to support offline mode when using html5 history api for url rewrites? For example, (hypothetically) I have a PWA SPA application at https://abc.xyz which has internationalization built in. So when I visit this link, the Vue router (which ideally could be any framework - vue, react, angular etc.) redirect me to https://abc.xyz /en . This works perfectly when I am online (ofcourse, the webserver is also handling this redirect so that app works even if you directly visit the said link). However, its a different story when I am offline.

Updating address bar window.location hash with scrollspy

馋奶兔 提交于 2019-12-04 19:08:59
I've got a menu with scrollspy (using twitter boostrap). I want update the window.location.hash when the user scrolls down to a next section. The following code works when the user scrolls down: $(window).on('activate.bs.scrollspy', function (e) { location.hash = $("a[href^='#']", e.target).attr("href") || location.hash; }); However it does not work very well when the user scrolls upwards. The reason for this is that setting a new location.hash triggers the browser to navigate towards that respective anchor. That triggers a chain reaction in which the user will instantly end up at the top of

How to change hashbang url to history API

心不动则不痛 提交于 2019-12-04 10:21:10
I'm using ember1.0-rc3, i want to change hashbang urls into normal url format (ie, www.site.com/admin#/page1 to www.site.com/admin/page1).In order to make this change,i use location: "history" in app router. But when i reload a page or bookmark a page doesn't works, it redirects to home page only.I want the options reload and bookmark in my app, without changing redirect urls in .htaccess file.Is there any way for it?Thanks in advance In order to use HTML5 history with a single page app like ember, your server must be have the behavior of rendering your main index.html file for any URL. The

Ajax with history.pushState and popstate - what do I do when popstate state property is null?

早过忘川 提交于 2019-12-04 10:01:27
问题 I'm trying out the HTML5 history API with ajax loading of content. I've got a bunch of test pages connected by relative links. I have this JS, which handles clicks on those links. When a link is clicked the handler grabs its href attribute and passes it to ajaxLoadPage(), which loads content from the requested page into the content area of the current page. (My PHP pages are set up to return a full HTML page if you request them normally, but only a chunk of content if ?fragment=true is

React Router: Query Param Match?

情到浓时终转凉″ 提交于 2019-12-04 08:19:16
According to the accepted answer to this question , React Router 4 doesn't match query parameters anymore. If I go from a URL matched by one of my <Route> s to the same URL with a different query string, the content doesn't seem to change. I believe this is because navigating between URLs that match the same <Route> doesn't change the content, but please correct me if I'm wrong. Given this, how do I use React Router for a set of URL's that need to differ only by query parameter? For example, many search engines and other sites that use search bars, including the site I am working on, use a

How can I make wordpress infinite scrolling change the URL?

狂风中的少年 提交于 2019-12-04 05:55:13
问题 I'm making a new blog for a startup who want a similar infinite scrolling effect to http://qz.com/ It also needs to include the URL changing as seen within the previously mentioned link. For the life of me I can't figure out how it's done, I think it uses the HTML5 History API, but I also had it working in internet explorer so maybe it doesn't? I would be incredibly grateful if someone could give me some pointers on how to make this work (using WordPress). 回答1: You can use infinite scroll to