admin管理员组文章数量:1310455
I want to be able to add certain behavior when a user clicks browser "back" and "forward" buttons.
Is there a way to say with JavaScript something like this:
backButton.onclick = function() {
// do something
}
forwardButton.onclick = function() {
//do something else
}
Is there a way to do that directly with JavaScript, without relying on any plugin?
I want to be able to add certain behavior when a user clicks browser "back" and "forward" buttons.
Is there a way to say with JavaScript something like this:
backButton.onclick = function() {
// do something
}
forwardButton.onclick = function() {
//do something else
}
Is there a way to do that directly with JavaScript, without relying on any plugin?
Share Improve this question edited Jun 12, 2013 at 17:49 KeithRules asked Jun 12, 2013 at 17:11 KeithRulesKeithRules 2071 gold badge4 silver badges15 bronze badges 3- No. You're looking for the HTML5 history API. – SLaks Commented Jun 12, 2013 at 17:12
- 1 It has already been answered here: stackoverflow./questions/4840457/… – Antoine Commented Jun 12, 2013 at 17:15
- Modified the question to clarify – KeithRules Commented Jun 12, 2013 at 17:19
1 Answer
Reset to default 7window.addEventListener("popstate", function(e) { // if a back or forward button is clicked
// do whatever
}
Works only in HTML5-enabled browsers, though.
For other browsers support, look into History.js
本文标签: javascriptBrowser back and forward button eventswithout a jQuery pluginStack Overflow
版权声明:本文标题:javascript - Browser back and forward button events, without a jQuery plugin - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741803579a2398367.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论