Get URL Parameters Total Three Method

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title></title>
	<meta charset="utf-8" />
    <script src="JS/jquery-1.9.0.js"></script>
    <script type="text/javascript">
        function GetQueryString1(name) {  
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");  
    var r = window.location.search.substr(1).match(reg);  //获取url中"?"符后的字符串并正则匹配
    var context = "";  
    if (r != null)  
         context = r[2];  
    reg = null;  
    r = null;  
    return context == null || context == "" || context == "undefined" ? "" :  context;  
}
       // alert(GetQueryString("q"));

        //------------------------------------------Method2
        function GetQueryString(name) {
            var reg = new RegExp(‘(^|&)‘ + name + ‘=([^&]*)(&|$)‘, ‘i‘);
            var r = window.location.search.substr(1).match(reg);
            if (r != null) {
                return unescape(r[2]);
            }
            return null;
        }
        //this Call:
        // alert(GetQueryString("q"));

        //---------------------------------------Method3
        function GetRequest() {
            var url = 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]] = unescape(strs[i].split("=")[1]);
                }
            }
            return theRequest;
        }
        var Request = new Object();
        Request = GetRequest();
    </script>
</head>

<body>

</body>
</html>
时间: 2024-10-15 10:39:50

Get URL Parameters Total Three Method的相关文章

Get URL parameters &amp; values with jQuery

原文: http://jquery-howto.blogspot.jp/2009/09/get-url-parameters-values-with-jquery.html In this post, I would like to share a little jQuery code snippet that makes getting URL parameters and their values more convenient. Recently, while working on one

How to get URL parameters with Javascript?

function getURLParameter(name) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null } So you can use: myvar = getURLParameter('myvar');

[Hapi.js] Route parameters

Routing is a fundamental aspect of any framework. In this lesson, you'll learn how to use path parameters in hapi's router. We'll also touch on how the router uses specificity to order routes internally. Router Param: http://localhost:8000/ztw // Wil

%3f URL --&gt; &#39;?&#39;拼接引发的问题

转载自:https://www.reddit.com/r/swift/comments/2w19kp/how_do_you_send_a_through_nsmutableurlrequest/ how do you send a ? through NSMutableURLRequest without encoding the ? as %3F (self.swift) submitted 1 year ago by xStory_Timex I have a enum Router.swi

Supported method argument types Spring MVC

Supported method argument types The following are the supported method arguments: Request or response objects (Servlet API). Choose any specific request or response type, for example ServletRequest or HttpServletRequest. Session object (Servlet API):

php curl 代理ip访问url

网上很多代理ip来访问url,具体干什么我也不知道,写代码: $header //请求头 $cookie //存储cookie $arrip //ip地址的地址及端口 $params // public function dorequest($arrip = array(),$url,$header,$timeout = 20000,$method=',$cookie'){ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch,

通过http请求获取指定url的页面

一.定义类 public class HttpWebResponseUtility { private static readonly string DefaultUserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)"; /// <summary> /// 创建GET方式的HTTP请求 /// </summa

url参数的分解与组合 &amp;&amp; 分页功能

url参数的分解与组合: 需求来源:分页功能中需要动态更改page参数. 实现:2个重要函数 1. 分解 1 parse_str(str, [array]); 2 3 /* 4 str: url字符串, array: 结果 5 例: 6 str : "id=1&page=2" 7 得array: 8 array["id"] = 1, array["page"] = 2 2. 组合 1 $str = http_build_query($ar

【struts2】&lt;s:url&gt;标签

<s:url>标签一般和超链接 <a>一起使用,用于带多个参数. <a href=" <s:url action=""> <s:param name=" " value=""></s:param> <s:param name=" " value=""></s:param> <s:param name=&