爱的勇气 百度网盘:如何将这个javascript变量传到jsp中?

来源:百度文库 编辑:高校问答 时间:2024/04/29 07:11:24
在js中已经定义了一个函数getMAC(),我想把他的值传到1.jsp这个页面中,怎么实现呢?

加个隐藏域
<input type=hidden name=xxx>
提交页面时把值赋给它
1.jsp接受参数

<script>
function give(){
form名.zhi.value = getMAC(),
}
</script>

<input type=hidden name=zhi>

然后提交form到1.jsp页面就行了

如果是提交类的,加个隐藏域
<input type=hidden name=xxx>
提交页面时把值赋给它
Onsubmit{...}

如果是link类的,直接在URL后加一个参数,在js中
window.navagate("1.js?mac=" + getMAC() );