history.js

how to catch a state change event ONCE with history.js?

若如初见. 提交于 2019-12-05 09:15:06
I have an example code below where if you click the links, then use back and forward, each state change will cause more and more hits on the 'statechange' event. Instead of the one that I expect. Links: https://github.com/browserstate/history.js http://docs.jquery.com/Downloading_jQuery Code: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>History start</title> </head> <body> <h1>Headline</h1> <hr> <div id="menu"> <ul> <li> <a href="page-1">Page 1</a> <div style="display:none;"> <h2>Page 1</h2> <p>Content 1</p> </div> </li> <li> <a

History.js onpopstate?

扶醉桌前 提交于 2019-12-05 08:25:12
问题 I am trying to implement History.js after learning to use the History API. However my popstate isn't working anymore. What is used in the History.js as the onpopstate ? In the history API you use onpopstate with event.state . What I need to know is what is used in History.js. Is it window.onstatechange and what does it return? 回答1: You can't tell it's from push or pop. This is by its design. You should not do anything before push event. Instead, you should pass all your required data to the

history.js - the correct implementation

拟墨画扇 提交于 2019-12-05 02:00:22
问题 i load my content on my site in a div called #container with JQuery/Ajax. I have to different types of of links: normal anchor-links JQuery-Triggers which fire an event when clicked on a specific div. Now i want to add functionality to support back and forward browser-buttons and bookmark functionality. I came across history.js, but i have a few problems with it and can't find a really easy tutorial how to use it properly. My links: <a href='#imprint' class='link_imprint'>Imprint</a> I read

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

Is there a way in History.js to know when the back button was pressed

我只是一个虾纸丫 提交于 2019-12-04 08:02:12
I've started to test History.js . After understanding how it works and that there is no popstate , instead there is statechange . I'm looking for a way to differ when the back button of the browser has been pressed. The reason is that I need to know the URL before the state moved, from the one I'm going to. With the gist the project includes, only the URL we go to is looked. I hope the solution is not to track latest URL visited in a global variable. Thanks I found the solutions on github to be a bit overdone for my purposes. I created a bool that is always true except right before when I used

History API html5, how to know when user clicked in next/back browser buttons? [duplicate]

时间秒杀一切 提交于 2019-12-04 04:02:36
This question already has an answer here: Is there a way to tell what direction the state is going with history.js? 2 answers I am getting familiar with the html5 History API, but I am using history.js to extend the compatibility, I have one question and it's that, how can I know in: History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate var State = History.getState(); // Note: We are using History.getState() instead of event.state /* Condition here to know if this change is a back or next button, and wich one?? */ }); This is my "whole"

History.js onpopstate?

我是研究僧i 提交于 2019-12-03 21:21:47
I am trying to implement History.js after learning to use the History API. However my popstate isn't working anymore. What is used in the History.js as the onpopstate ? In the history API you use onpopstate with event.state . What I need to know is what is used in History.js. Is it window.onstatechange and what does it return? benck You can't tell it's from push or pop. This is by its design. You should not do anything before push event. Instead, you should pass all your required data to the first parameter. History.pushState(data,title,url) Then retrieve data from onstatechange and do some

history.js - the correct implementation

旧巷老猫 提交于 2019-12-03 17:05:00
i load my content on my site in a div called #container with JQuery/Ajax. I have to different types of of links: normal anchor-links JQuery-Triggers which fire an event when clicked on a specific div. Now i want to add functionality to support back and forward browser-buttons and bookmark functionality. I came across history.js, but i have a few problems with it and can't find a really easy tutorial how to use it properly. My links: <a href='#imprint' class='link_imprint'>Imprint</a> I read that it is better for SEO to use <a href="imprint/" ... but that URL would not be found on my server. So

Comparison between Sammy.js/History.js/Nav.js [closed]

杀马特。学长 韩版系。学妹 提交于 2019-12-03 08:41:38
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. I was looking around for Single Page navigation handlers. Sammy.js was bit okay to crack so i created a sample SPA with proper navigation. Works great till now.(moreover, the fact the sammy.js is used by Twitter.. made me more curious.. ) :) No issues!!