url传值取值
程序员文章站
2024-02-01 23:32:34
...
<!DOCTYPE html> <html> <body> <a href="test2.html?id=1">消息关键词</a> </body> </html>
<!DOCTYPE html> <html> <body> <h1>将test1.html页面<a>链接传值带到test2.html页面</h1> </body> </html> <script> var getUrlString = function (name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } //id值 var abc = getUrlString("id"); </script>