• 获取地址栏参数


    /* *****************************
    * 获取参数值
    * @param name 参数名称
    * @returns 参数值
    ***************************** */
     
    CloudShareCommon.prototype.getQueryString = function (name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        var context = "";
        if (r != null)
            context = r[2];
        reg = null;
        r = null;
        return context == null || context == "" || context == "undefined" ? "" : context;
    };    
     
    --------------------------------------------------------------------------------------------------------------------
    //获取URL参数
    function getQueryString(name) {
        var url = window.location.search; //获取url中"?"符后的字串
        var theRequest = new Object();
        if (url.indexOf("?") != -1) {
            var str = url.substr(1);
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = decodeURI(strs[i].split("=")[1]);
            }
        }
    return theRequest[name];
    }    
     
    --------------------------------------------------------------------------------------------------------------------
    var a="https://www.baidu.com?user_id=324300147&mobile=15802038598"
    
    function parseQueryString(url) {
        var json = {};
        var arr = url.substr(url.indexOf('?') + 1).split('&');
        arr.forEach(function(item) {
            var tmp = item.split('=');
            json[tmp[0]] = tmp[1];
        })
        return json;
    }
    
    alert(parseQueryString(a).mobile);
  • 相关阅读:
    select SCOPE_IDENTITY()用法
    SQL 2005 with(nolock)详解
    .NET4进行COM互操作导出数据到Excel
    Counterfeit Dollar 1013 pku
    Numbers that count 1016 PKU
    对局问题 ——取火柴问题(转)
    (a^b) mod c
    对局问题——放硬币问题(转)
    对局问题 ——取石子问题– 1堆(转)
    Follow My Logic 1048 PKU
  • 原文地址:https://www.cnblogs.com/queende7/p/8668892.html
Copyright © 2020-2023  润新知