欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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>