js控制页面带参跳转

js控制页面带参跳转:

方法1:html中href没有指向跳转页面
html:
<input class="weui-input phone-input" id="edit-phone-input" type="number" oninput="if(value.length>11) value=value.slice(0,11)"  pattern="/^13[0-9]{9}$|(^14)[5,7]\d{8}$|15[012356789]\d{8}$|18[0-9]{9}$|17[0-9]{9}$/" placeholder="请输入您的手机号"/>

<input class="weui-input code-input" type="number" placeholder="输入验证码">

<a href="javascript:;" class="weui_btn weui_btn_primary btn-gradient-confirm" id="confirm-edit-phone">确定修改</a>

Js:
var value1=$('#edit-phone-input').val();
var value2=$('.code-input').val();
alert(value1);
alert(value2);
var link ="personal-message.html" + '?value1='+value1 + '&value2='+value2;
window.location.href=link;   //这样就可以传过去了

 

方法2:html的href中指向了跳转页面:
html: <input class="weui-input phone-input" id="edit-phone-input" type="number" oninput="if(value.length>11) value=value.slice(0,11)" pattern="/^13[0-9]{9}$|(^14)[5,7]\d{8}$|15[012356789]\d{8}$|18[0-9]{9}$|17[0-9]{9}$/" placeholder="请输入您的手机号"/> <input class="weui-input code-input" type="number" placeholder="输入验证码"> <a href="personal-message.html" class="weui_btn weui_btn_primary btn-gradient-confirm" id="confirm-edit-phone">确定修改</a> Js: var value1=$('#edit-phone-input').val(); var value2=$('.code-input').val(); this.href = this.href + '?value1='+value1 + '&value2='+value2; //这种方式可以在下一个页面中获取前一个页面传在url中的参数

 

 

posted @ 2017-11-06 22:57  安静的嘶吼  阅读(12993)  评论(0编辑  收藏  举报