如何在phonegap和jquerymobile中传递url参数? [英] How to pass url parameter in phonegap and jquerymobile?

查看:126
本文介绍了如何在phonegap和jquerymobile中传递url参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jquery mobile和phonegap开发一个应用程序.我需要将url参数从jqm页面传递到另一个页面.此jqm代码可以正常工作.

I am developing a app using jquery mobile and phonegap. I need to pass a url parameter from jqm page to another page.This jqm code is wokring fine.

第1页

<a data-icon="maps" data-role="button" href="page2.html?id=test">Click</a> 

第2页

$.urlParam = function(name) {
    var results = new RegExp('[\\?&amp;]' + name + '=([^&amp;#]*)').exec(window.location.href);
    return results[1] || 0;
}
alert($.urlParam('id'));

但是当我将其添加到phonegap中时,它不起作用.任何想法如何在phonegap中使用它.

But when I add the same in to phonegap its not working. Any ideas how to use this in phonegap.

谢谢

推荐答案

我建议您使用此方法.为您更轻松.

I suggest you use this method. More easier for you.

第1页

html

<a id="mapButton" data-icon="maps" data-role="button" >Click</a> 

javascript

javascript

$("#mapButton").click(function() {
    sessionStorage.param1 = "test";
    window.location.replace("page2.html");
});

第2页

alert(sessionStorage.param1);

这篇关于如何在phonegap和jquerymobile中传递url参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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