html中使用[removed].href()跳转和传递参数。

1.在按钮上添加onclick时间,并传递参数给js函数,参数可以为input中输入的值,也可以为jsp中获取的值。

οnclick="searchInfo(form1.workername)"

在js函数里调用时要加.value

οnclick="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"));
 %>

parent.location.href是用来在当前页面的上一层页面进行跳转的。具体实现的方法是通过在JavaScript使用parent.location.href属性来改变上一层页面的URL地址,从而实现页面的跳转。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [jslocation.href,parent.location.href,top.location.href的用法](https://blog.csdn.net/weixin_43553153/article/details/112426719)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *2* [关于jswindow.location.href,location.href,parent.location.href,top.location.href的用法](https://blog.csdn.net/s13596191285/article/details/128459046)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] - *3* [关于js[removed].href,location.href,parent.location.href,top.location.href的用法与区别](https://download.csdn.net/download/weixin_38640984/13589277)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值