Javascript 在linkjquerymobile中传递参数
我目前正在使用以下代码将参数从主页传递到jquery mobile中的弹出窗口:Javascript 在linkjquerymobile中传递参数,javascript,jquery,jquery-mobile,jquery-mobile-popup,Javascript,Jquery,Jquery Mobile,Jquery Mobile Popup,我目前正在使用以下代码将参数从主页传递到jquery mobile中的弹出窗口: <a onclick= DisplayEditIdPopUP('" . $row ['IdentificationTypeID'] ."','".$custid."','". $num."','".$row ['CustomerIdentificationId']."')>Edit</a> 谢谢有几种解决方案: 解决方案1: 您可以使用changePage传递值: $.mobile.c
<a onclick= DisplayEditIdPopUP('" . $row ['IdentificationTypeID'] ."','".$custid."','". $num."','".$row ['CustomerIdentificationId']."')>Edit</a>
谢谢有几种解决方案: 解决方案1: 您可以使用changePage传递值:
$.mobile.changePage('page2.html', { dataUrl : "page2.html?paremeter=123", data : { 'paremeter' : '123' }, reloadPage : true, changeHash : true });
这样读:
$(document).on('pagebeforeshow', "#index", function (event, data) {
var parameters = $(this).data("url").split("?")[1];;
parameter = parameters.replace("parameter=","");
alert(parameter);
});
$(document).on('pagebeforeshow', '#index',function (e, data) {
alert(data.prevPage.attr('id'));
});
例子:
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="widdiv=device-widdiv, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>
</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js">
</script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<script>
$(document).on('pagebeforeshow', "#index",function () {
$(document).on('click', "#changePage",function () {
$.mobile.changePage('second.html', { dataUrl : "second.html?paremeter=123", data : { 'paremeter' : '123' }, reloadPage : false, changeHash : true });
});
});
$(document).on('pagebeforeshow', "#second",function () {
var parameters = $(this).data("url").split("?")[1];;
parameter = parameters.replace("parameter=","");
alert(parameter);
});
</script>
</head>
<body>
<!-- Home -->
<div data-role="page" id="index">
<div data-role="header">
<h3>
First Page
</h3>
</div>
<div data-role="content">
<a data-role="button" id="changePage">Test</a>
</div> <!--content-->
</div><!--page-->
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="widdiv=device-widdiv, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>
</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://www.dragan-gaic.info/js/jquery-1.8.2.min.js">
</script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<!-- Home -->
<div data-role="page" id="second">
<div data-role="header">
<h3>
Second Page
</h3>
</div>
<div data-role="content">
</div> <!--content-->
</div><!--page-->
</body>
</html>
例如:
解决方案3:
您还可以通过以下方式访问上一页中的数据:
$(document).on('pagebeforeshow', "#index", function (event, data) {
var parameters = $(this).data("url").split("?")[1];;
parameter = parameters.replace("parameter=","");
alert(parameter);
});
$(document).on('pagebeforeshow', '#index',function (e, data) {
alert(data.prevPage.attr('id'));
});
prevPage对象保存完整的上一页
解决方案4:
作为最后一个解决方案,我们有一个漂亮的本地存储HTML实现。它只适用于HTML5浏览器(包括Android和iOS浏览器),但通过页面刷新,所有存储的数据都是持久的
if(typeof(Storage)!=="undefined") {
localStorage.firstname="Dragan";
localStorage.lastname="Gaic";
}
例如:
查找有关它们的更多信息您尚未在第二秒通过onclick事件…..我知道,这是我的问题,是否有一种方法可以在不使用onclick事件的情况下将参数传递到弹出窗口。我对问题进行了编辑,使之更清楚。