This question already has an answer here: How can I get query string values in JavaScript? 73 answers 你去那里:http://jsfiddle.net/mm6Bt/1/ function getURLParam(key,target){ var values = []; if (!target) target = location.href; key = key.replace(/[[]/, "\[").replace(/[]]/, "\]"); var pattern = key + '=([^&#]+)'; var o_reg = new RegExp(pattern,'ig'); while (true)
这个问题在这里已经有了答案: 我怎样才能在JavaScript中获取查询字符串值? 73个答案 你去那里:http://jsfiddle.net/mm6Bt/1/ function getURLParam(key,target){ var values = []; if (!target) target = location.href; key = key.replace(/[[]/, "\[").replace(/[]]/, "\]"); var pattern = key + '=([^&#]+)'; var o_reg = new RegExp(pattern,'ig'); while (true){ var matches
This question already has an answer here: How can I get query string values in JavaScript? 73 answers You can make use of split() var url = 'http://localhost:17241/Chart.aspx?id=11' var params = url.split('?'); var id=params[1].split('=')[1]; //params[1] will contain everything after ? console.log(id); EDIT To get the url inside the var url replace the first line with var url = window.
这个问题在这里已经有了答案: 我怎样才能在JavaScript中获取查询字符串值? 73个答案 你可以使用split() var url = 'http://localhost:17241/Chart.aspx?id=11' var params = url.split('?'); var id=params[1].split('=')[1]; //params[1] will contain everything after ? console.log(id); 编辑 要获取var url用第一行替换 var url = window.location.href; 它被称为查询字符串 这里是功能, function getPar
Possible Duplicates: JavaScript query string get querystring with jQuery Is there an object/method in javascript to turn a string like this: "param1=2¶m2=1¶m3=5" into some sort of dictionary, so that I can refer to each element as mystring['param1'] or mystring[0]? Can jQuery help here? this is my try. var a = 'param1=2¶m2=1¶m3=5'; var
可能重复: JavaScript查询字符串 用jQuery获取querystring 在javascript中是否有一个对象/方法将字符串转换为某种字典,例如“param1 = 2&param2 = 1&param3 = 5”,以便我可以将每个元素引用为mystring ['param1']或mystring [0] ? jQuery可以在这里帮助吗? 这是我的尝试。 var a = 'param1=2¶m2=1¶m3=5'; var b = a.split('&'); var final ={}; $.each(b, function(x,y){ var te
This question already has an answer here: How can I get query string values in JavaScript? 73 answers You can use a regex to do this. var qualityRegex = /(?:^|[&;])quality=([^&;]+)/g, matches, qualities = []; while (matches = qualityRegex.exec(window.location.search)) { qualities.push(decodeURIComponent(matches[1])); } jsFiddle. The qualities will be in qualities
这个问题在这里已经有了答案: 我怎样才能在JavaScript中获取查询字符串值? 73个答案 你可以使用正则表达式来做到这一点。 var qualityRegex = /(?:^|[&;])quality=([^&;]+)/g, matches, qualities = []; while (matches = qualityRegex.exec(window.location.search)) { qualities.push(decodeURIComponent(matches[1])); } 的jsfiddle。 质量将是qualities 。 对于希望能够匹配url中的非
Possible Duplicate: How can I get query string values? Trying to get a regex (Javascript). Input: url.html?id=14114&yolo=hahaha Output: id=14114 yolo=hahaha So this is what i have done so far: (&|?)(.*?)=(.*?) How do I also include the red circled regions? 这种模式如何: (?|&)([^=]+)=([^&]+) [^&?]*?=[^&?]* tested here http://fiddle.re/bmdu
可能重复: 我怎样才能得到查询字符串值? 试图得到一个正则表达式(Javascript)。 Input: url.html?id=14114&yolo=hahaha Output: id=14114 yolo=hahaha 所以这就是我迄今为止所做的: (&|?)(.*?)=(.*?) 我怎么也包括红色圆圈区域? 这种模式如何: (?|&)([^=]+)=([^&]+) [^&?]*?=[^&?]* 在这里测试 http://fiddle.re/bmdu
Possible Duplicate: Get query string values in JavaScript how can i get the get variable in javascript? i want to pass it in jquery function. function updateTabs(){ //var number=$_GET['number']; how can i do this? alert(number); $( "#tabs" ).tabs({ selected: number }); } var $_GET = {}; if(document.location.toString().indexOf('?') !== -1) { var query =
可能重复: 在JavaScript中获取查询字符串值 我怎样才能得到JavaScript中的变量? 我想通过它在jQuery的功能。 function updateTabs(){ //var number=$_GET['number']; how can i do this? alert(number); $( "#tabs" ).tabs({ selected: number }); } var $_GET = {}; if(document.location.toString().indexOf('?') !== -1) { var query = document.location
Possible Duplicate: get querystring with jQuery How do I get the value of a querystring into a textbox using jQuery? Lets say the url is http://intranet/page1.php?q=hello I would like the "hello" to be in the textbox. In my programming archive I have this function: function querystring(key) { var re=new RegExp('(?:\?|&)'+key+'=(.*?)(?=&|$)','gi'); var r=[], m;
可能重复: 用jQuery获取querystring 如何使用jQuery将查询字符串的值导入文本框? 可以说,网址是http://intranet/page1.php?q = hello 我希望“hello”在文本框中。 在我的编程档案中,我有这个功能: function querystring(key) { var re=new RegExp('(?:\?|&)'+key+'=(.*?)(?=&|$)','gi'); var r=[], m; while ((m=re.exec(document.location.search)) != null) r.push(m[1]); return r; }
Possible Duplicate: Use the get paramater of the url in javascript Get query string values in JavaScript In Javascript, how can I get the parameters of a URL string (not the current URL)? like: www.domain.com/?v=123&p=hello Can I get "v" and "p" in a JSON object? Today (2.5 years after this answer) you can safely use Array.forEach . As @ricosrealm suggests, de
可能重复: 在javascript中使用获取参数的url 在JavaScript中获取查询字符串值 在Javascript中,如何获取URL字符串的参数(不是当前URL)? 喜欢: www.domain.com/?v=123&p=hello 我可以在JSON对象中获得“v”和“p”吗? 今天(在答案后的2.5年),您可以安全地使用Array.forEach 。 正如@ricosrealm所建议的那样,在这个函数中使用了decodeURIComponent 。 function getJsonFromUrl() { var query = location.
Possible Duplicate: How can I get query string values? I have the following URL: http://www.mysite.co.uk/?location=mylocation1 What I need is to get the value of location from the URL into a variable and then use it in a jQuery code: var thequerystring = "getthequerystringhere" $('html,body').animate({scrollTop: $("div#" + thequerystring).offset().top}, 500); Does anyone know how to grab
可能重复: 我怎样才能得到查询字符串值? 我有以下网址: http://www.mysite.co.uk/?location=mylocation1 我需要的是从URL中获取location的值到一个变量中,然后在jQuery代码中使用它: var thequerystring = "getthequerystringhere" $('html,body').animate({scrollTop: $("div#" + thequerystring).offset().top}, 500); 有谁知道如何使用JavaScript或jQuery获取该值? 来自:http://jquery-howto.blogspot.com/
Possible Duplicate: How can I get query string values? I need to parse the query string www.mysite.com/default.aspx?dest=aboutus.aspx . How do I get the dest variable in JavaScript? Here is a fast and easy way of parsing query strings in JavaScript: function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split('&'); for (var
可能重复: 我怎样才能得到查询字符串值? 我需要解析查询字符串www.mysite.com/default.aspx?dest=aboutus.aspx 。 如何在JavaScript中获得dest变量? 这是一种在JavaScript中解析查询字符串的快捷方法: function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split('&'); for (var i = 0; i < vars.length; i++) { var pair = vars[i