html中使用window.location.href()跳转和传递参数。
2018-02-02 12:40
585 查看
1.在按钮上添加onclick时间,并传递参数给js函数,参数可以为input中输入的值,也可以为jsp中获取的值。
onclick="searchInfo(form1.workername)"
在js函数里调用时要加.value
onclick="alterInfo(<%=work1.getCode()%>,<%=work1.getName()%>,<%=work1.getDetail()%>,<%=work1.getCount()%>)"
2.然后调用js中的函数实现跳转
function insert(){
window.location.href("workinsert.jsp");
}
function alterInfo(code,name,detail,count){
var string1 = code;
var string2 = name;
var string3 = detail;
var number = count;
window.location.href("alterInfo.jsp?code="+string1+"&name="+string2+"&detail="+string3+"&count="+number);
}
3.然后在跳转到的页面中使用request.getParameter()来获取参数
<%
String code = request.getParameter("code");
String name = request.getParameter("name");
String detail = request.getParameter("detail");
int count = Integer.parseInt(request.getParameter("count"));
%>
onclick="searchInfo(form1.workername)"
在js函数里调用时要加.value
onclick="alterInfo(<%=work1.getCode()%>,<%=work1.getName()%>,<%=work1.getDetail()%>,<%=work1.getCount()%>)"
2.然后调用js中的函数实现跳转
function insert(){
window.location.href("workinsert.jsp");
}
function alterInfo(code,name,detail,count){
var string1 = code;
var string2 = name;
var string3 = detail;
var number = count;
window.location.href("alterInfo.jsp?code="+string1+"&name="+string2+"&detail="+string3+"&count="+number);
}
3.然后在跳转到的页面中使用request.getParameter()来获取参数
<%
String code = request.getParameter("code");
String name = request.getParameter("name");
String detail = request.getParameter("detail");
int count = Integer.parseInt(request.getParameter("count"));
%>
相关文章推荐
- 在一个页面文件中(JSP 或者HTML)使用href 跳转另一个页面时使用Js中获取传递过来的参数
- window.location.href 跳转页面时传递参数并且在新页面接收参数
- html两个页面跳转时传递参数location.search
- javaweb使用 window.location.href 传中文参数 乱码问题
- 使用window.location.href跳转页面在IE和FF浏览器中路径不一致的问题总结
- window.location.href传递js对象参数及获取参数
- window.location.href 带参数跳转 如何获取值(解决)
- ASP.Net中使用 window.location.href 实现页面跳转
- Window.location.href以post方式传递参数的方法
- window.location.href以post方式传递参数
- ASP.Net中使用 window.location.href 实现页面跳转(转自:永恒的回忆)
- 使用response.sendirect("html/employee.html?"+java.net.URLEncoder.encode(param.substri) 重定向传递参数,并隐藏跳转地址
- js 使用 window.location.href 无法跳转
- jsp html中 window.location.href动态添加参数
- 解决在chrome浏览器使用js的window.location.href跳转页面失败的问题
- window.location.href跳转页面,问号传参并将参数转为json对象
- Window.location.href以post方式传递参数的方法
- 如何使用js来实现通过href完成多个html页面之间的传递参数
- window.location.href传递汉字参数
- window.location.href 跳转失效问题