zoukankan      html  css  js  c++  java
  • JS URL 参数

    JS URL 参数
            var request = {
                     QueryString : function(val) {
                     var uri = window.location.search;
                     var re = new RegExp("" +val+ "\=([^\&\?]*)", "ig");
                     return ((uri.match(re))?(uri.match(re)[0].substr(val.length+1)):null);
                     },
                     QueryStrings : function() {
                     var uri = window.location.search;
                     var re = /\w*\=([^\&\?]*)/ig;
                     var retval=[];
                     while ((arr = re.exec(uri)) != null)
                     retval.push(arr[0]);
                     return retval;
                     },
                    setQuery : function(val1, val2) {
                     var a = this.QueryStrings();
                     var retval = "";
                     var seted = false;
                     var re = new RegExp("^" +val1+ "\=([^\&\?]*)$", "ig");
                     for(var i=0; i<a.length; i++) {
                     if (re.test(a[i])) {
                     seted = true;
                     a[i] = val1 +"="+ val2;
                     }
                     }
                     retval = a.join("&");
                     return "?" +retval+ (seted ? "" : (retval ? "&" : "") +val1+ "=" +val2);
                     }
                    }    
          
            var request2 = {
                     QueryString : function(val2) {
                     var uri2 = window.location.search;
                     var re2 = new RegExp("" +val2+ "\=([^\&\?]*)", "ig");
                     return ((uri2.match(re2))?(uri2.match(re2)[1].substr(val2.length+1)):null);
                     }
                    }  
  • 相关阅读:
    检查IP地址是否有效(delphi)
    Oracle 常用操作
    DBGrid中顯示行號的終極解決方案(Delphi篇)
    从零开始学Java 第24章 网络聊天室
    JavaScript的循环结构和经典题目
    html5/css3布局(一)
    html常用的基本标签
    HTML5——css基础语法
    JavaScript函数使用和DOM节点
    C语言Ⅰ|博客作业07
  • 原文地址:https://www.cnblogs.com/hznet/p/1805292.html
Copyright © 2011-2022 走看看