获取页面传来的参数

<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. IDEA中SpringBoot启动报错Error:(11, 39) java: 找不到符号

    确保不是依赖没有导入或者编码不对问题后 如果还是不行 可以试试以下方式 解决办法 将图片框中Delegate IDE build 勾选 然后重新启动即可

  2. MySQL数据导入报错:Got a packet bigger than‘max_allowed_packet’bytes的问题

    修改my.cnf,需重启mysql. 在 [MySQLd] 部分添加一句(如果存在,调整其值就可以): max_allowed_packet=512M 查找MySql的配置文件my.cnf所在路径参考 ...

  3. LocalDateTime与Date相互转换

    LocalDateTime 转 Date LocalDateTime localDateTime=LocalDateTime.now() Date date = Date.from(localDate ...

  4. vue-子组件创建/注册/使用流程

    流程分为三步 非单文件组件:(实际不用,因为很麻烦,框架都是多文件组件) 局部注册 1.创建一个组件 const school = Vue.extend({ // 传入配置对象 // 子组件配置对象不 ...

  5. github fmt库语法+范例(fmt version :7.0.1)

    !!版权声明:本文为博主原创文章,版权归原文作者和博客园共有,谢绝任何形式的 转载!! 作者:mohist fmt fmt 源码: https://github.com/fmtlib/fmt 本文翻译 ...

  6. 【LeetCode】213. House Robber II 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/house-rob ...

  7. 【LeetCode】784. Letter Case Permutation 解题报告 (Python&C++)

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

  8. J. Bottles

    J. Bottles time limit per test 2 seconds memory limit per test 512 megabytes input standard input ou ...

  9. oracle函数listagg使用

    作用 可以实现将多列记录聚合为一列记录,实现数据的压缩 语法结构 listagg(measure_expr,delimiter) within group ( order by order_by_cl ...

  10. 使用JavaScript 中的Math对象和勾股定理公式,计算鼠标的位置与页面图片中心点的距离,根据距离对页面上的图片进行放大或缩小处理。距离远时图片放大,距离近时图片缩小

    查看本章节 查看作业目录 需求说明: 使用JavaScript 中的Math对象和勾股定理公式,计算鼠标的位置与页面图片中心点的距离,根据距离对页面上的图片进行放大或缩小处理.距离远时图片放大,距离近 ...