pushstate

Backbone route with push state not working on page refresh

左心房为你撑大大i 提交于 2019-12-02 21:01:25
问题 var Backbone = require('backbone'), SellerProfileView = require('./views/seller/SellerProfileView'); var Router = Backbone.Router.extend({ routes: { ":user_name" : "sellerProfile" }, sellerProfile: function (username) { "use strict"; var sellerProfile = new SellerProfileView({username: username}); } }); module.exports = Router var Router = require('./router'), Backbone = require('backbone'), $ = require('jquery'); var app = { init: function () { "use strict"; Backbone.$ = $; this.router = new

How to index dynamic pages to google using html5 pushstate method?

旧巷老猫 提交于 2019-12-02 20:01:15
问题 I am building a fully jquery powered website, so i am loading all pages dynamically using ajax to achieve fancy transitions between pages and maximize user experience. Here is my javascript code: $(function() { var path = _.compact(location.pathname.split("/")); if(path.length<2){ path = 'home' }else{ path = path[path.length-1]; } activepage = path; $('.nav a').click(function(e) { href = $(this).attr("href"); loadContent(href); // HISTORY.PUSHSTATE window.history.pushState('', 'New URL: '

How to update the twitter share button URL with dynamic content?

喜欢而已 提交于 2019-12-02 19:49:27
I initialize the tweet button at the beginning of my app, after user interaction the current window's location is updated using HTML5 pushState, but the twitter button is still sharing the previous URL from when it was initialized. How do I update the URL that twitter uses? I figured this out. Here's how to make this work. The general idea is: In your HTML set the class of your <a> for the twitter share button to be something other than .twitter-share-button . Also give the <a> a style="display:none;" . In your HTML, where you want the twitter share button to appear, create a <div> (or <span>

Moving back to a pushState entry that used ajax

妖精的绣舞 提交于 2019-12-02 18:22:40
I'm having an issue with the following situation. User visits site User clicks link which uses history.pushState to update the url Partial page content loaded via ajax (using jQuery) User clicks regular link which loads a new page User clicks back to return to the pushState entry The page now displays only the page partial that was retrieved via ajax I've souped up a site using pushState for various things and the result is a shockingly responsive web app, but this issue is preventing me from using this. Here's a sample of the code: $('a').live('click', function(){ history.pushState({}, '',

How to “browser back” when using pushState?

戏子无情 提交于 2019-12-02 17:52:55
问题 I have this code: window.history.pushState(newUrl, "", newUrl); My question is, how to make sure that when doing pushState the browser back button will function as normal or in other words should go "back"? (without using jQUery) 回答1: The normal behaviour for the back button is for the browser to go back to the previous document, but when you use pushState , there isn't a previous document. The point of pushState is to keep the browser on the same document while updating the URL. This is

Backbone route with push state not working on page refresh

倖福魔咒の 提交于 2019-12-02 13:44:29
var Backbone = require('backbone'), SellerProfileView = require('./views/seller/SellerProfileView'); var Router = Backbone.Router.extend({ routes: { ":user_name" : "sellerProfile" }, sellerProfile: function (username) { "use strict"; var sellerProfile = new SellerProfileView({username: username}); } }); module.exports = Router var Router = require('./router'), Backbone = require('backbone'), $ = require('jquery'); var app = { init: function () { "use strict"; Backbone.$ = $; this.router = new Router(); $(document).ready(function () { Backbone.history.start({ pushState: true, route: '/' }); });

How to index dynamic pages to google using html5 pushstate method?

主宰稳场 提交于 2019-12-02 11:50:24
I am building a fully jquery powered website, so i am loading all pages dynamically using ajax to achieve fancy transitions between pages and maximize user experience. Here is my javascript code: $(function() { var path = _.compact(location.pathname.split("/")); if(path.length<2){ path = 'home' }else{ path = path[path.length-1]; } activepage = path; $('.nav a').click(function(e) { href = $(this).attr("href"); loadContent(href); // HISTORY.PUSHSTATE window.history.pushState('', 'New URL: '+href, href); e.preventDefault(); }); // THIS EVENT MAKES SURE THAT THE BACK/FORWARD BUTTONS WORK AS WELL

How to “browser back” when using pushState?

丶灬走出姿态 提交于 2019-12-02 11:19:25
I have this code: window.history.pushState(newUrl, "", newUrl); My question is, how to make sure that when doing pushState the browser back button will function as normal or in other words should go "back"? (without using jQUery) The normal behaviour for the back button is for the browser to go back to the previous document, but when you use pushState , there isn't a previous document. The point of pushState is to keep the browser on the same document while updating the URL. This is accompanied by DOM changes applied with JavaScript. It is a simulation of going to a new page. To make the back

Append parameter in url without reloading page

大憨熊 提交于 2019-12-02 03:29:49
I am using following code to append param to url. This is working fine but when parameter is appended in url, page is getting reloaded. I want to use this functionality without reloading the page . function insertParam(key, value) { key = escape(key); value = escape(value); var kvp = document.location.search.substr(1).split('&'); var i=kvp.length; var x; while(i--) { x = kvp[i].split('='); if (x[0]==key) { x[1] = value; kvp[i] = x.join('='); alert('sdfadsf'); break; } } if(i<0) {kvp[kvp.length] = [key,value].join('=');} //this will reload the page, it's likely better to store this until

pushState change - equivalent to Chrome Extension onHistoryStateUpdated

£可爱£侵袭症+ 提交于 2019-12-01 12:30:43
I'm porting a Chrome extension to a Firefox extension and due to the nature of the website that it runs on, I need to monitor the pushState . Chrome Extensions has a handy way to handle this: chrome.webNavigation.onHistoryStateUpdated . The way that I use it in the Chrome extension is as follows: chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) { var tabUrl = details.url; if (isTabUrlValid(tabUrl)) { $.get(tabUrl, function(data) { var videoUrl = $(data).find('meta[itemprop=contentURL]').prop('content'); videoUrl = validateUrl(videoUrl); videoUrl5k = make5kUrl(videoUrl);