获取页面传来的参数

<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. FastAPI 学习之路(六十)打造系统的日志输出

    我们要搭建日志系统,我们使用loguru,挺不错的一个开源的日志系统.可以使用 pip install loguru 我们在common创建log.py使用方式也很简单 import os impor ...

  2. BERT生成能力改进:分离对话生成和对话理解

    NLP论文解读 原创•作者 | 吴雪梦Shinemon 研究方向 | 计算机视觉 导读说明: NLP任务大致可以分为NLU(自然语言理解)和NLG(自然语言生成)两种,NLU负责根据上下文去理解当前用 ...

  3. 【LeetCode】面试题 16.11. 跳水板 Diving Board (Python)

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

  4. 刷完 900 多题后的首次总结:LeetCode 应该怎么刷?

    「负雪明烛」公众号是负雪明烛维护的一个算法题解公众号,致力于帮助大家刷题.找工作.欢迎关注. 大家好,我是负雪明烛.今天跟大家聊一聊「LeetCode应该怎么刷?」这个话题. 我是大二的时候开始接触 ...

  5. 【LeetCode】814. Binary Tree Pruning 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 后序遍历 日期 题目地址:https://leetc ...

  6. Mod Tree(hdu2815)

    Mod Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Su ...

  7. 永中dcs实现浏览器上面的手绘效果

    永中dcs是一款在线预览各种办公文件的网络产品,我们可以只用一个浏览器就可以实现对word,ppt和excel等文件的在线浏览,在其中有一个在线手绘功能很有特色,让我们来探一探它的实现原理吧. 第一, ...

  8. Myeclipse查看jdk源代码

    过程如下: 1.点 "window"-> "Preferences" -> "Java" -> "Install ...

  9. springboot中word转pdf,加盖电子印章

    概述 在开发过程中,word转pdf的方式有很多种有jar包的方式,有安装openoffice的方式,但是使用有的jar包有license认证,不然会生成水印,综合几种方法我采用了libreoffic ...

  10. springboot单元测试为什么排除junit-vintage-engine

    https://blog.csdn.net/Ber_Bai/article/details/117001443 如果不排除,就需要使用@RunWith注解? 25-springboot整合单元测试指定 ...