window.location.href如何传递参数

2025-05-09 00:14:47

1、鼠标点击打开HBuidler软件,如图所示:

window.location.href如何传递参数

2、点击菜单栏新建-->Web项目,如图所示:

window.location.href如何传递参数

3、输入web项目名window,然后点击完成按钮,如图所示:

window.location.href如何传递参数

4、然后在html文件中键入代码:<!DOCTYPE html><挢旗扦渌;html> <head>稆糨孝汶; <meta charset="utf-8" /> <title>window.location.href如何传递参数?</title> </head> <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script> <script type="text/javascript">$(document).ready(function(){ $("#btn").click(function(){ var name=$("#name").val(); alert("需要传递的名字参数:"+name); window.location.href="index2.html?name="+name; });}); </script> <body> <button id="btn">传递参数</button> <form > 姓名:<input type="text" id="name" value="张三"/> </form> </body></html>

window.location.href如何传递参数

5、然后点击运行按钮--->浏览器运行,如图所示:

window.location.href如何传递参数

6、浏览器查看运行结果,然后点击传递参数按钮,如图所示:

window.location.href如何传递参数

7、可以看到弹出需要传递的参数为张三,如图所示:

window.location.href如何传递参数
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢