获取页面传来的参数

<div>
<script>
function GetQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) return (r[2]); return null;
}
var sname = GetQueryString("name");
if (sname != null) {
var sname_ = decodeURIComponent(sname);
alert(sname_);
}
</script>
</div>

测试

abcd.html?name=xyz

应该弹出xyz

查找参数是否存在

location.search.match

<div>
<script>
if (location.search.match('debugGome')) {
var scriptLoad = document.createElement('script');
scriptLoad.type = 'text/javascript';
scriptLoad.src = '//js.gomein.net.cn/csr/common/vconsole/vconsole.js';
document.getElementsByTagName('head')[0].appendChild(scriptLoad);
setTimeout(function () {
var domVconsole = document.querySelector('#__vconsole');
if (domVconsole) {
domVconsole.style.fontSize = '.28rem';
}
}, 1000)
}
</script>
</div>

通过location.search来获取页面传来的参数的更多相关文章

  1. js通过location.search来获取页面传来的参数

    这篇文章主要介绍了通过window.location.search来获取页面传来的参数,经测试是OK的 ? 1 2 3 4 5 function GetQueryString(name) { var ...

  2. Action接收页面传来的参数方法

    接收页面传来的参数方法 1.第一种:在action中设置相应的变量 在相应的action中设置与将要传进来的参数名相同的变量 eg: 页面传给后台两个参数 name=chance & age ...

  3. js获取页面传来参数的方法

    function GetQueryString(name) { var reg = new RegExp("(^|&)" + name + "=([^&] ...

  4. 获取url传来的参数

    //根据传递过来的参数name获取对应的值 function getParameter(name) { var reg = new RegExp("(^|&)" + nam ...

  5. js前端获取页面传递的参数

    转载的,先记下: UrlParm = function () { // url参数 var data, index; (function init() { data = []; index = {}; ...

  6. Servlet/jsp 中 获取页面所有传递参数

    Enumeration en = request.getParameterNames(); while(en.hasMoreElements()){ String el = en.nextElemen ...

  7. window.location属性用法及解决一个window.location.search为什么为空的问题

    通常用window.location该属性获取页面 URL 地址: 1.什么是window.location? 比如URL:http://b.a.com:88/index.php?name=kang& ...

  8. js中location.search、split()HTML5中localStorage

    1. location.search在客户端获取Url参数的方法 location.search是从当前URL的?号开始的字符串 如:http://www.baidu.com/s?wd=baidu&a ...

  9. jquery知识location.search

    location.search在客户端获取Url参数的方法 location.search是从当前URL的?号开始的字符串如:http://www.baidu.com/s?wd=baidu&c ...

随机推荐

  1. 人工智能论文解读精选 | PRGC:一种新的联合关系抽取模型

    NLP论文解读 原创•作者 | 小欣   论文标题:PRGC: Potential Relation and Global Correspondence Based Joint Relational ...

  2. 【LeetCode】1579. 保证图可完全遍历 Remove Max Number of Edges to Keep Graph Fully Traversable

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题思路 并查集 代码 欢迎加入组织 日期 题目地址:https ...

  3. 【LeetCode】256. Paint House 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 日期 题目地址:https://leetco ...

  4. 第三十五个知识点:给针对ECDLP问题的Pollard rho,Pollard "Kangaroo",parallel Pollard rho攻击的一个粗略的描述

    第三十五个知识点:给针对ECDLP问题的Pollard rho,Pollard "Kangaroo",parallel Pollard rho攻击的一个粗略的描述 我们的目标是对任 ...

  5. Zookeeper基础教程(五):C#实现Zookeeper分布式锁

    分布式锁 互联网初期,我们系统一般都是单点部署,也就是在一台服务器完成系统的部署,后期随着用户量的增加,服务器的压力也越来越大,响应速度越来越慢,甚至出现服务器崩溃的情况. 为解决服务器压力太大,响应 ...

  6. 使用.NET 6开发TodoList应用(22)——实现缓存

    系列导航及源代码 使用.NET 6开发TodoList应用文章索引 需求 有的时候为了减少客户端请求相同资源的逻辑重复执行,我们会考虑使用一些缓存的方式,在.NET 6中,我们可以借助框架提供的中间件 ...

  7. java 短路与(||)时报错The operator || is undefined for the argument type(s) int, boolean

    今天在使用短路与时,报错The operator || is undefined for the argument type(s) int, boolean 代码如下: 最后发现是少了一个=,比较要使 ...

  8. VC 2010 Express 学生版(中文版)

    Microsoft Visual C++ 2010 Express 学生版 下载传送门(提取码:r7sm) 如何安装 拿到压缩文件后,解压到桌面(别怕,安装完后这个文件夹是可以删除的). 在 &quo ...

  9. hisql orm 框架insert数据写入教程

    hisql.net 官网(文档编写中) HiSql 源码(github) https://github.com/tansar/HiSql git clone https://github.com/ta ...

  10. Chromium Windows Build

    https://chromium.googlesource.com/chromium/src/+/refs/heads/main/docs/windows_build_instructions.md ...