jQuery移动将参数从一页传递到另一页 [英] jQuery mobile passing parameter from one page to another

查看:95
本文介绍了jQuery移动将参数从一页传递到另一页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用表单来导航表单参数,并将其从一个页面传递到另一页面,并通过查询字符串传递给

I am currently using a form to navigate and pass form parameters from one one page to another and through a query string.

FirstPage表单代码

<form name="input" action="new_page.html" method="get">
Username: <input type="text" name="user" />
<input type="submit" value="Submit" />
</form>

在新页面中,我尝试使用document.URL获取查询字符串值.当旧页面指向新页面时,仅执行新页面的正文内容.脚本文件不会在新页面中执行.因此,我无法在新页面中获取查询字符串值.

In the new page I am trying to get the query-string value using document.URL. When the old page directs to the new page only the body contents of the new page are executed. The script files are not executed in the new page. Thus, I am not able to grab the query string values in the new page.

将参数通过表单从一个页面传递到另一页面的过程对于常规HTML页面而言效果很好,但是在jQuery Mobile的情况下无效.

The process of passing parameters through form from one page to another works well for a regular HTML page, but does not work in case of jQuery Mobile.

谁能建议我一种将参数从一个jQuery Mobile页面传递到另一页面的更好方法.任何帮助表示赞赏.

Can any one suggest me a better way of passing parameters from one jQuery Mobile page to another. Any help is appreciated.

推荐答案

关于更改页面时脚本未执行:

Regarding your scripts not executing when you change pages: jQueryMobile page events not firing when navigating to a different html page

jQuery Mobile使用AJAX将新页面提取到DOM中,这是创建jQuery Mobile网站所必须习惯的.这意味着应该在document.readywindow.load上运行的代码应绑定到其他事件,例如:pagecreatepageshowpageinit.这是有关事件的jQuery Mobile文档(可能很有启发性): http://jquerymobile.com/demos/1.0/docs/api/events.html (请注意,页面事件大约从一半开始).

jQuery Mobile uses AJAX to pull new pages into the DOM, which is something you'll have to get used to for creating jQuery Mobile websites. This means that code that is supposed to run on document.ready or window.load should be bound to other events like: pagecreate, pageshow, pageinit. Here's jQuery Mobile's documentation on events (which can be quite enlightening): http://jquerymobile.com/demos/1.0/docs/api/events.html (Note that page-events start about half-way down).

这篇关于jQuery移动将参数从一页传递到另一页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆