input type button onclick location.href怎么传参数

 我来答
胡胜赖
2015-07-22 · TA获得超过519个赞
知道答主
回答量:124
采纳率:66%
帮助的人:17.4万
展开全部
<input type=button onclick="window.location.href('连接')">或<input type=button onclick="location='连接' ">或<input type=button onclick="location.href='连接' ">或<input type=button onclick="window.open('连接')">
本回答被提问者和网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2014-04-11
展开全部
<input type="button" onclick="location.href='<URL>'" value="请点击我跳转"/>
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
年度最佳人品
2018-01-18 · TA获得超过143个赞
知道答主
回答量:241
采纳率:100%
帮助的人:76.6万
展开全部
window.location.href = "url?key1=value1&key2=value2&....";
如demo.html?uersid=123&password=123456这样。
取值只需要在DEMO页面用JS,
function getRequest() {
var url = decodeURI(location.search); //获取url中?后的字符串 decondeURI解码url
var theRequest = new Object();
if (url.indexOf("?") != -1) {
var str = url.substr(1);
var strs = str.split("&");
for (var i = 0; i < strs.length; i++) {
theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
}
}
return theRequest;
}
使用:
var request = getRequest();
var userid = request["userid"] == null ? "" : request["userid"];
var password = request["password"] == null ? "" : request["password"];
注意因为编码问题url传中文参数会乱码,所以整个href里面的类容需(url+参数)要先用
encodeURI(url+参数)这个原生方法编码一下,在通过上面function中的decodeURI(location.search);解码就可以取到正常的中文字符了。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2014-04-11
展开全部
这问题 去看书
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 2条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式