查询字符串Javascript

fla*_*404 1 javascript

使用javascript,如何在查询字符串中添加一些数据?

基本上我想将window.screen.height和window.screen.width信息添加到查询字符串中,以便我可以使用其他登录信息通过电子邮件发送它.

或者,如何使用相同的数据填充几个隐藏字段,正在提交表单,以便我可以从那里提取它?

谢谢,R.

Bra*_*ons 6

我认为后一种选择更容易实现.例如,如果您有这样的隐藏字段:

...
<input type="hidden" name="screenheight" id="screenheight" value="" />
<input type="hidden" name="screenwidth" id="screenwidth" value="" />
...
Run Code Online (Sandbox Code Playgroud)

然后JavaScript将是:

<script type="text/javascript">
document.getElementById('screenheight').value = window.screen.height;
document.getElementById('screenwidth').value = window.screen.width;
</script>
Run Code Online (Sandbox Code Playgroud)