首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JQM (jQueryMobile)访问网址历史?

JQM (jQueryMobile)访问网址历史?
EN

Stack Overflow用户
提问于 2011-03-25 00:39:02
回答 2查看 5.8K关注 0票数 2

我有一个问题,能够从AJAX响应从多页布局表单提交链接回主页

结构

index.php具有多页协议(index.php#agreement)

#agreement有一个表单正在使用默认的AJAX调用提交给(agreement.php)

在agreement.php中,我可以返回到预期的最后一个页面(#agreement),但现在我想返回到index.php页面。

我可以很容易地放入href="index.php",但是会话失去了它的值。

有没有退回两步的方法?或者访问URL历史记录并指向特定页面,而不会丢失表单中的任何数据?

我在index.php中使用以下代码绑定了agreement.php

代码语言:javascript
复制
$('#agreement_status').live('pageshow',function(event, ui){
    // Button action
    $('#back_home').click(function(){
        window.history.back(); // this goes back one page to index.php#agreement
        window.history.back(-2); // this goes back one page to index.php#agreement
        $.mobile.changePage("#index", "slideup"); // this works but appends the hashtag in the URL which breaks the other functionality 
    });
});

agreement.php中,我有以下代码

代码语言:javascript
复制
<a id="back_home" 
   data-role="button" 
   data-icon="home" 
   data-theme="z" 
   data-inline="true" 
   style="float:right;">
    Home
</a>
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-04-02 03:01:29

好吧,这不是对我问题的真正回答,但它确实解决了我的问题:

返回按钮代码,在锚标记中使用agreement.php -rel=“back”选项,并添加一个名称/id为agreement_status的div标记

代码语言:javascript
复制
<a data-rel="back" 
   data-role="button" 
   data-icon="home" 
   data-theme="z" 
   data-inline="true" 
   style="float:right;">
    Home
</a>

在index.php页面中,将以下代码添加到您的java脚本中

代码语言:javascript
复制
$('#agreement_status').live('pagehide',function(event, ui){
    window.history.back();
});

当agreement_status页面被隐藏时,会触发pagehide,因此您将进入#协议页面。然后使用window.history.back();我们能够返回到index.php页面,并且仍然保留所有数据,而不需要刷新页面

票数 1
EN

Stack Overflow用户

发布于 2011-03-30 13:53:32

尝尝这个

代码语言:javascript
复制
        window.location.href = "/index.php";
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5422492

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档