http://techfunda.com/Tools/XmlToJson

http://beautifytools.com/xml-to-json-converter.php

https://www.fyneworks.com/jquery/xml-to-json/

https://github.com/abdmob/x2js

1.html:

<a href="2.html?name=geovindu&sex=woman&age=12">test getQueryString</a>

2.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>javascript获取url参数和script标签中获取url参数</title>
<script type="text/javascript" src="jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="js1.js?a=abc&b=汉字&c=123"></script>
<script type="text/javascript">
//lastest: url paramter: //测试链接:<a href="2.html?name=geovindu&sex=woman&age=12">test getQueryString</a>
var queryStrings=function() {//get url querystring
var params=document.location.search,reg=/(?:^\?|&)(.*?)=(.*?)(?=&|$)/g,temp,args={};
while((temp=reg.exec(params))!=null) args[temp[1]]=decodeURIComponent(temp[2]);
return args;
};
//只取一个:
var queryString=function(key){
return (document.location.search.match(new RegExp("(?:^\\?|&)"+key+"=(.*?)(?=&|$)"))||['',null])[1];
} </script>
</head> <body>
<div id="urlparamter"></div>
<div id="all"></div>
<div id="scriptparamter"></div>
<div id="allscript"></div>
<script type="text/javascript">
var args=queryStrings();
document.getElementById("all").innerHTML=args.name+" | "+args.sex+" | "+args.age+",all";
//alert(args.name+" | "+args.sex+" | "+args.age);
var argsname=queryString("name");
var argssex=queryString("sex");
var argsage=queryString("age");
document.getElementById("urlparamter").innerHTML =argsname+","+argssex+","+argsage; </script>
</body> </html>

  js1.js:

/*http://css.dusystem.com/example/index.html
window.location.protocol = "http:"
window.location.host = "css.dusystem.com"
window.location.pathname = "example/index.html"
http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
http://www.cnblogs.com/sohighthesky/archive/2010/01/21/1653126.html
http://www.codeproject.com/Tips/574956/How-to-get-URL-and-QueryString-value-in-an-ASP-NET test: <a href="1.html?id=5&type=1&flag=0" title="d">test</a>
*/ var strget="du"; function getArgs(strParame)
{
var args = new Object( );
var query = location.search.substring(1); // Get query string
var pairs = query.split("&"); // Break at ampersand
for(var i = 0; i < pairs.length; i++) {
var pos = pairs[i].indexOf('='); // Look for "name=value"
if (pos == -1) continue; // If not found, skip
var argname = pairs[i].substring(0,pos); // Extract the name
var value = pairs[i].substring(pos+1); // Extract the value
value = decodeURIComponent(value); // Decode it, if needed
args[argname] = value; // Store as a property
}
return args[strParame]; // Return the object
} //script paramter:
var getScriptArgs=function(){
//获取多个参数
var scripts=document.getElementsByTagName("script"),
script=scripts[scripts.length-1],//因为当前dom加载时后面的script标签还未加载,所以最后一个就是当前的script
src=script.src,
reg=/(?:\?|&)(.*?)=(.*?)(?=&|$)/g,
temp,res={};
while((temp=reg.exec(src))!=null) res[temp[1]]=decodeURIComponent(temp[2]);
return res;
}; //
var argsscript=getScriptArgs();
//document.getElementById("scriptparamter").innerHTML =argsscript.a+" | "+argsscript.b+" | "+argsscript.c;
strget=argsscript.a;
//alert(argsscript.a+" | "+argsscript.b+" | "+argsscript.c+","+strget);
//document.getElementById("txtput").value=strget;
//document.getElementById("scriptparamter").innerHTML ="ge";
//txtput //假如上面的js是在这个js1.js的脚本中<script type="text/javascript" src="js1.js?a=abc&b=汉字&c=123//"><//script> var getScriptArg=function(key){//获取单个参数
var scripts=document.getElementsByTagName("script"),
script=scripts[scripts.length-1],
src=script.src;
return (src.match(new RegExp("(?:^\\?|&)"+key+"=(.*?)(?=&|$)"))||['',null])[1];
};
alert(getScriptArg("c")); //set value
window.onload = function () { getCommunitys(strget);
} function getCommunitys(str) {
$("#scriptparamter")[0].innerHTML="ges";
//document.getElementById("scriptparamter").innerHTML =str;
document.getElementById("txtput").value=str;
}

  http://www.codeproject.com/Tips/574956/How-to-get-URL-and-QueryString-value-in-an-ASP-NET

How to get the query string by javascript?的更多相关文章

  1. Reading query string values in JavaScript

    时间 2016-01-23 13:01:14  CrocoDillon’s Blog 原文  http://crocodillon.com/blog/reading-query-string-valu ...

  2. Are query string keys case sensitive?

    Are query string keys case sensitive? @gbjbaanb's answer is incorrect: The RFCs only specify the all ...

  3. convert URL Query String to Object All In One

    convert URL Query String to Object All In One URL / query string / paramas query string to object le ...

  4. nodejs笔记三--url处理、Query String;

    URL--该模块包含用以 URL 解析的实用函数. 使用 require('url') 来调用该模块. 一.parse函数的基础用法 parse函数的作用是解析url,返回一个json格式的数组,请看 ...

  5. <原>ASP.NET 学习笔记之HTML helper中参数何时会是路由参数,何时又会是query string?

    HTML helper中参数何时会是路由参数,何时又会是query string?   @Html.ActionLink("Edit", "Edit", new ...

  6. query string parameters 、 Form Data 、 Request Payload

    微信小程序ajax向后台传递参数的时候总是报400错误 然后看了一下network 发现是query string parameters,但是我写的header如下 header:{ "Co ...

  7. springMVC接收参数的区别form data与query string parameters与request payload

    在AJAX请求中,我见过有三种form表单数据类型提交. 第一种:form data, 第二种:query string parameters,第三种:request payload. 在google ...

  8. http 请求参数之Query String Parameters、Form Data、Request Payload

    Query String Parameters 当发起一次GET请求时,参数会以url string的形式进行传递.即?后的字符串则为其请求参数,并以&作为分隔符. 如下http请求报文头: ...

  9. asp.net query string 及 form data 遇到的编码问题

    当遇到此问题时,脑海里闪过的第一个解决方案是设置 web.config 的编码.但一想,就某一个页面的需求而导致其他跟着妥协,不是好的解决方案.于是网上搜索答案,下面做个小分享,遗憾的是研究不够深入, ...

随机推荐

  1. 网站CSS选择器性能讨论

    CSS选择符由一些初始化参数组成,这些参数指明了要应用这个CSS规则的页面元素.作为一个网站的前端开发工程师,应该避免编写一些常见的开销很大的CSS选择符模式,尽量编写高效的CSS选择符,从而加快页面 ...

  2. SAP ECC CO 配置

    SAP ECC 6.0 Configuration Document Controlling (CO) Table of Content TOC \o \h \z 1. Enterprise Stru ...

  3. [论文笔记] Legacy Application Migration to the Cloud: Practicability and Methodology (SERVICES, 2012)

    Quang Hieu Vu, Rasool Asal: Legacy Application Migration to the Cloud: Practicability and Methodolog ...

  4. Jquery实现ready()的源码

    function bindReady(){ if ( readyBound ) return; readyBound = true; // Mozilla, Opera and webkit nigh ...

  5. Routine Problem(数学)

     Routine Problem time limit per test 1 second memory limit per test 256 megabytes input standard inp ...

  6. Android使用SurfaceView实现墨迹天气的风车效果

    SurfaceView也是继承自View,它和我们以前接触到的View(Button.TextView等)最大的不同是,SurfaceView可以有一个单独的线程进行绘制,这个线程区别于UI线程(主线 ...

  7. 【转载】S2SH

    说说最多人用的SSH或SSI吧,现在用的比较多的应该就是struts2.x+spring3.X+hibernate4.X或hibernate3.X了吧,mybatis用的人也有,方便有DBA的公司. ...

  8. Linux下查看tcp连接数及状态

    netstat -n | awk ‘/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}’ TIME_WAIT 8947FIN_WAIT1 15FIN_W ...

  9. 单链表List的C实现

    头文件———————————————————————————————— //单链表的实现 #ifndef _LIST_H_ #define _LIST_H_ #include <stdlib.h ...

  10. ubuntu14.04使用IceGridAdmin图形界面

    打开网页: http://www.rpmfind.net/linux/RPM/index.html输入搜索: icegrid-gui下载文件: icegrid-gui-3.5.1-2.mga4.x86 ...