关于jQuery history.back();问题

草原的雨夜 2015-08-17 05:06:34
在网站开发过程中,有时会用到返回上一页功能,但是如果是返回一个页面,那倒没什么问题,如果是返回多个页面,就会出现死循环的问题,简单画一个示意图
a.html->b.html->c.html->d.html;这个是访问顺序
如果要返回,在d.html中调用history.back();返回c.html,这时,如果在c.html中再次调用history.back();则又会回到d.html,以后会一直循环下去,原因就是history中记录队列的时候返回的那个页面也记录到了历史记录中,所以导致返回不能不间断的使用,只能隔一个使用一下,如果history提供删除也可以解决,但问题是没有开放删除,不知道各位有没有什么好的办法,就在history的基础上解决。
以前的解决方案基本是自己实现了一套,现在有点闲工夫,讨论下这个问题。集思广益。
...全文
451 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
JC释 2016-03-14
  • 打赏
  • 举报
回复
我也遇到这样的问题了,刷新的情况下会导致history出现回退问题,目前没找到方法解决,只能别手动刷新当前页。比如UC浏览器上带有的刷新当前页功能就会导致history混乱。
草原的雨夜 2015-08-18
  • 打赏
  • 举报
回复
<a href="javascript:history.back()">后退</a>简单的一句代码,没有刻意去刷新,猜测是刷新这个原因导致的。
clark_kidd 2015-08-17
  • 打赏
  • 举报
回复
怎么刷新法?用什么代码?
clark_kidd 2015-08-17
  • 打赏
  • 举报
回复
为什么history.back()后还要刷新?
草原的雨夜 2015-08-17
  • 打赏
  • 举报
回复
另外需要说明下,简单的这些情况我都测试过的,之所以选择自己再实现一下是因为不稳定,有的情况下会出现死循环的现象。出现的概率还比较大,所以才花时间重新做了一个返回相关的功能。
草原的雨夜 2015-08-17
  • 打赏
  • 举报
回复
这个我试过是可以,但是有些情况下会一直循环,也就是不稳定,我的理解是如果返回后刷新,则会出现这种情况,如果不刷新就不会,但问题是无法判断有没有刷新,按道理是不会刷新的。 另外我测试了好多次,如果单纯是一个简单的页面,似乎不会刷新,但如果页面复杂点,里面有多个ajax则偶尔会出现这情况。不知道是为什么? 有没有办法返回后直接禁止刷新,或者即使有刷新,只要删除掉历史记录就可以。
clark_kidd 2015-08-17
  • 打赏
  • 举报
回复
1.htm
<a href="2.htm">去2</a>
<a href="javascript:history.back()">后退</a>
2.htm
<a href="3.htm">去3</a>
<a href="javascript:history.back()">后退</a>
3.htm
<a href="4.htm">去4</a>
<a href="javascript:history.back()">后退</a>
4.htm
<a href="javascript:history.back()">后退</a>
试试
clark_kidd 2015-08-17
  • 打赏
  • 举报
回复
不会的 “如果在c.html中再次调用history.back();则又会回到d.html” 你理解错了,会回到 b.html
中文名: WordPress 宝典 原名: WordPress Bible 别名: WordPress,Bible,宝典,PHP,CMS 作者: Aaron Brazell资源格式: PDF 出版社: Wiley书号: 978-0-470-56813-2发行时间: 2010年 地区: 美国 语言: 英文 简介:   WordPress 是一种使用 PHP 语言和 MySQL 数据库开发的开源、免费的 Blog(博客,网志)引擎,用户可以在支持 PHP 和 MySQL 数据库的服务器上建立自己的 Blog。   WordPress 是一个功能非常强大的博客系统,插件众多,易于扩充功能。安装和使用都非常方便。目前 WordPress 已经成为主流的 Blog 搭建平台。   WordPress 的原版是英文版的,UTF-8 编码,最新版本为 2.9。为满足日益庞大的中文用户需求开辟了中文官方站点且提供中文版程序下载。还有爱好者开发了中文语言包,使其可以支持中文。不过,由于使用的编码原因,中文字符截断时会出现乱码。不过桑葚网友制作的中文 WordPress 工具箱插件可以解决这个问题。   WordPress 可以说是世界上目前最先进的 weblog 程序。目前开发的程序大多都是根据它仿造的。它更能把握搜索引擎,在你使用 WordPress 并掌握几种插件后,对于优化将不用过多的操心,它会为你想的更多。   WordPress有许多第三方开发的免费模板,安装方式简单易用。不过要做一个自己的模板,则需要你有一定的专业知识。比如你至少要懂的HTML代码、CSS、PHP等相关知识。 Install WordPress and go beyond blogging WordPress is so flexible that developers are now tapping it to create robust applications for content, contact, and e-mail management. Whether you're a casual blogger or programming pro, this comprehensive guide covers WordPress from the basics through advanced application development. Learn how to use custom plugins and themes, retrieve data, maintain security, use social media, and modify your blog without changing any core code. You'll even get to know the ecosystem of products that surrounds this popular, open-source tool. Enhance your blog\'s findability in the search engines and beyond Discover hooks and leverage the WordPress event-driven programming interface Create WordPress widgets in only a few minutes Explore alternate uses of WordPress Enhance your blog with WordPress MU Ensure your plugins maintain future compatibility Create highly customizable and dynamic themes using template tags Learn best security practices as a user and developer Companion Web Site Visit www.wiley.com/go/wordpressbible for all of the author's example files from the book. Install, secure, and maintain WordPress Extend WordPress with plugins and themes Enhance your blog with WordPress MU 目录: Credits About the Author About the Technical Editor Contents Preface WordPress Versioning Getting the Most Out of This Book Using the Margin Icons Part I: Getting Started with WordPress Chapter 1: Learning About WordPress A Brief History of WordPress Leveraging the WordPress Community WordPress by the Numbers 10 Things You Need to Know About WordPress Understanding Open Source and the General Public License Summary Chapter 2: Installing and Configuring WordPress System Requirements Choosing a Web Server Installing WordPress Summary Chapter 3: WordPress, SEO, and Social Media Marketing Understanding the Basics of Search Engine Optimization Leveraging Social Networks to Extend Your Blog Summary Chapter 4: Finding Help in the WordPress Support System Using the WordPress Codex Staying in the Loop with Mailing Lists Finding Help in the WordPress Support Forums Summary Part II: Working with Plugins Chapter 5: Extending WordPress with Plugins Understanding WordPress Hooks Writing Your Own Plugin Extending the WordPress Admin Creating Events with Actions Modifying Content with Filters Using Multi-Argument Hooks Localizing Plugins Summary Chapter 6: Widgetizing WordPress Using Widgets in WordPress Building Widgets with the Widget API Widgetizing Your Theme Summary Chapter 7: Understanding the WordPress Database Class Examining the Schema and Properties of the Database Class Adding Data to MySQL with WordPress Retrieving Data from MySQL with WordPress Preventing SQL Injection Summary Chapter 8: Dissecting the Loop and WP_ Query Defining the Loop Wrangling the Loop with Plugins Developing Custom and Multiple Loops Using Loops Strategically Summary Part III: Working with Themes and Template Tags Chapter 9: Using Free or Premium Themes Understanding the User Experience Finding and Implementing Free Themes Finding and Implementing Premium Themes Summary Chapter 10: Understanding the Template File Hierarchy Looking at the Minimum Necessary Template Files Understanding the Common Template Files Enhancing the User Experience with Template Files Developing Custom Template Files Summary Chapter 11: Adding JavaScript and CSS to Themes Examining the jQuery and Prototype Frameworks Leveraging WordPress’ JavaScript Libraries Examining WordPress Plugins that Use JavaScript Effects Looking at Theme Styles Summary Chapter 12: Dissecting the Comment Loop, Template Tags, and Theme Best Practices Using Hooks in Themes Implementing Scripts in Themes Using Template Tags to Make Themes Dynamic Creating Conversations with Threaded Comments and Paged Comments Personalizing the Reader Experience with Avatars Summary Part IV: Creating Content Chapter 13: Navigating the Content Production Experience Customizing Your Workspace Leveraging the Elements of Content Creation Hacking Your Experience: Getting the Most Out of Writing Summary Chapter 14: Using Offline Editors What Is XML-RPC? Understanding XML-RPC Security Risks Looking at Offline Blog Editors Summary Part V: Keeping Up with the Joneses: Maintenance and Upgrades Chapter 15: Performing Automatic Upgrades Meeting the Minimum Automatic Upgrade Requirements Disabling the “Upgrade Nag” Performing Automatic Upgrades Using SSH for Automatic Upgrades Summary Chapter 16: Moving to WordPress and Backing It Up Moving a Blog to WordPress Importing Tags into WordPress Looking at Backup Routines Summary Chapter 17: WordPress Maintenance and Security Upgrading WordPress Choosing an FTP Client Practicing Sound WordPress Security Summary Chapter 18: Caching Strategy to Ensure WordPress Scales Understanding Caching Using WordPress Caching Mechanisms Optimizing PHP with Opcode Caching Caching MySQL with HyperDB and the Query Cache Harnessing the “Cloud” Summary Chapter 19: Understanding WordPress Roles and Capabilities Looking at WordPress Roles and Capabilities Using the Role Manager Plugin Summary Part VI: Alternate Uses for WordPress Chapter 20: Using WordPress for Alternative Blogging Photoblogging with WordPress Implementing a Twitter-style Blog Using Press This for a Tumble Blog Summary Chapter 21: WordPress as a Content Management System Using WordPress as a Content Management System Understanding Enterprise WordPress Needs Conveying a Consistent Message and Brand Understanding When a Blog Is Not a Blog Summary Part VII: Looking at the WordPress Ecosystem Chapter 22: Leveraging WordPress MU and Multi-Blog Functionality Installing and Configuring WordPress MU Converting a WordPress Blog to WordPress MU Understanding WordPress MU Plugin Nuances Adapting to WordPress MU Summary Chapter 23: Adding User Forums with bbPress Installing bbPress Finding bbPress Plugins Understanding the bbPress Theme System Summary Chapter 24: Creating Your Own Social Network with BuddyPress What Is BuddyPress? Configuring BuddyPress Comparing BuddyPress and WordPress Development Looking at BuddyPress Theme Concepts Extending BuddyPress Summary Chapter 25: Using BackPress as a Development Framework Defining BackPress Developing with BackPress Solving BackPress Dependencies Summary Chapter 26: WordPress.com and the Automattic Products About Automattic Taking a Look at Automattic’s Propriety Products Using WordPress.com Themes Getting Your Plugin Included in WordPress.com Buying Premium WordPress.com Features Summary Chapter 27: Leveraging Automattic Products Obtaining a WordPress.com API Key Using Akismet to Kill Spam Making Use of WordPress.com Stats Engaging Readers with IntenseDebate Crowdsourcing with PollDaddy Summary Part VIII: Appendixes Appendix A: WordPress Hook Reference Using Actions Using Filters Hook Reference: Alphabetical Listing Hook Reference: General Uses Summary Appendix B: Template Tags Understanding the Template Tag Concept Breaking Down the WordPress Templating System Summary Appendix C: What About PHP 5? PHP 4 versus PHP 5: Understanding Core Differences WordPress and PHP 5 Summary Appendix D: WordPress Hosting Features and Requirements of Web Hosts Types of Web Hosts Summary Appendix E: WordPress Vendors and Professional Services Top Consultants in the WordPress Community Directory of Automattic-Recommended Consultants Summary Appendix F: WordPress in Government WordPress Use in the Federal Government WordPress Use Outside the United States Summary Appendix G: WordPress in Major Media Newsroom Challenges for WordPress Roadmapping WordPress in Major Media Summary Appendix H: The General Public License Preamble GNU GENERAL PUBLIC LICENSE Index

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧