可以通过网址参数来传递·
A网页:
1
2
3
4
5
6
7
8
9
10
|
$(
function
(){
$(
'#a按钮'
).on(
'click'
,
function
(){
//在原页面跳转
location.href=
"B网页地址.html?参数名1=参数值1&参数名2=参数值2"
//或者 新开页面
window.open (
'B网页地址.html?参数名1=参数值1&参数名2=参数值2'
,
'newwindow'
,
'height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no'
) ;
});
});
|
B页面:可以使用js来获取参数值,代码如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
var
parm1 = getParam(
'参数名1'
);
var
parm2 = getParam(
'参数名2'
);
function
getParam(paramName) {
paramValue =
""
;
isFound =
false
;
if
(
this
.location.search.indexOf(
"?"
) == 0 &&
this
.location.search.indexOf(
"="
) > 1) {
arrSource = unescape(
this
.location.search).substring(1,
this
.location.search.length).split(
"&"
);
i = 0;
while
(i < arrSource.length && !isFound) {
if
(arrSource[i].indexOf(
"="
) > 0) {
if
(arrSource[i].split(
"="
)[0].toLowerCase() == paramName.toLowerCase()) {
paramValue = arrSource[i].split(
"="
)[1];
isFound =
true
;
}
}
i++;
}
}
return
paramValue;
}
|