There are two ways to parse the query parameters of a URL into a Dictionary object:1. Manual parsing1 functionGetquerystringargs (URL) {2url = URL = =NULL?Window.location.href:url;3 varQS = url.substring (Url.lastindexof ("?") + 1);4 varargs = {};5 varItems = qs.length > 0? Qs.split (' ')) : []
1. Extract parameters from URLs
Has the following strings:
Var linkURL = 'HTTP: // localhost: 8080/String/string_6.html? Nickname = xiaoxi mountain age = 24 # id1 ';For a real URL address, you can use js to read relevant information in location to obtain some information. The following lists some information:Copy codeThe Code is as follows: location. origin: http: // localhost [domain]Location. pathname:/project_js/Javascript/js_basic/demo/String/st
These two methods mainly supplement the toquerystring method of toqueryparams and object in the sring section previously skipped in prototype analysis.
1. Extract parameters from URLs
Has the following strings:
VaR linkurl = 'HTTP: // localhost: 8080/string/string_6.html? Nickname = xiaoxi mountain age = 24 # id1 ';
For a real URL address, you can use js to read relevant information in location to obtain some information. The following lists some in
1. Extract parameters from URLsHas the following strings:Var linkURL = 'HTTP: // localhost: 8080/String/string_6.html? Nickname = xiaoxi mountain age = 24 # id1 ';For a real URL address, you can use js to read relevant information in location to obtain some information. The following lists some information:Copy codeThe Code is as follows:Location. origin: http: // localhost [domain]Location. pathname:/project_js/Javascript/js_basic/demo/String/string
1. You enter a URL into the browser (enter a URL address)2.The Browser looks up the IP address for the domain name (browser to find IP addresses for domain names)The first step in navigation is to find its IP address by the domain name that is accessed. The DNS lookup process is as follows:
Browser cache – The browser caches DNS records for a period of time. Interestingly, the operating system does
If the URL's query string contains Chinese characters, the Request.getparameter method does not get the correct information without special handling, due to the following two mechanisms
The browser automatically encodes the special characters in the URL, such as requesting a localhost:8080/testjsp/loginmiddle.jsp?name= test, and the URL that is actually
How to obtain url query parameters using JavaScript
This example describes how to obtain url query parameters in JavaScript. Share it with you for your reference. The specific implementation method is as follows:
?
1 2 3 4 5 6 7 8 9 10
Function getQueryVariable (variable) { Var
"iOS development"-canopenurl:failed for URL: "XX"-Error: "This app is not allowed to query for scheme XX"Collection/bookmark/share for width under 768pxConsole outputis the output of the console after I launch a Xcode 7 + IOS 9 App.This is not the case in Xcode 6.4 + IOS 8 o'clock, because "in order to enforce enhanced data access security, iOS9 defaults to all nsurlconnection , cfurl , nsurlsession
This topic appeared in a number of companies in the interview, of course, is too typical, the solution is nothing more than Chaizi or with regular matching to solve, I personally strongly recommend to use regular matching, because the URL allows users to enter at will, if the use of Chaizi characters, there is no fault-tolerant, Will cause the whole JS error. And the regular does not have this problem, he only matched the correct pairing, illegal all
The method for obtaining url query parameters in JavaScript is javascripturl.
This example describes how to obtain url query parameters in JavaScript. Share it with you for your reference. The specific implementation method is as follows:
Function getQueryVariable (variable) {var
If you want to query the URL, too long will affect the effect, so the article mentions to add a column for example URL_CRC, through the CRC32 function to query,
But I do not understand why the "this drawback is to maintain the hash" in the text, and manually create trigger maintenance will not have side effects?
Reply to discussion (solution)
BizarreCRC32 is
This article mainly introduces how to obtain url query parameters by using JavaScript to analyze parameters in URLs, for more information about how to obtain url query parameters in JavaScript, see the following example. Share it with you for your reference. The specific implementation method is as follows:
Function
is the output of the console after I launch a Xcode 7 + IOS 9 App.This is not the case in Xcode 6.4 + IOS 8 o'clock, because "in order to enforce enhanced data access security, iOS9 defaults to changing all HTTP requests from, and from, to NSURLConnection CFURL NSURLSession HTTPS requests: IOS9.X-SDK compile, default NSURLConnection CFURL NSURLSession The TLS 1.2 (SSL 3.1) protocol is used uniformly for all HTTP requests from, and to be issued. 】Here's the solution:① If your output message is a-
JS in the URL to get the specified search string, the main use of the Location object implementation, nonsense less said, on the code.1 functiongetsearchstring (key) {2 //gets the character after the URL?3 varstr =Location.search;4str = str.substring (1, str.length);5 6 //separate strings in to get an array of elements like Name=xiaoli7 vararr = Str.split ("");8 varobj =NewObject ()
Suppose url= "Http://write.blog.csdn.net/postedit?id=5search=ok"function Getargs () {var args = {};//Create the object that holds the data var qs = location.search.length > 0? location.search.substring (1): "; Get the query string and remove the start question mark var items = qs.split (' '); Split fractional GROUP BY string var item = NULL, name = NULL, value = null;//adds each item to the Args object on
The situation is, for example, I enter the following URL to IE browser:http://localhost:8090/RPT_TYSH_JL_ZD_DETAIL.html?pageIndex=1year=2018month=7merAddress=鹿港There will be a 404 error.The workaround is to modify the configuration in IE:Click the Settings button in the upper right of IE browser and check the "Send UTF-8 string for Intranet url" in Internet Options--advanced---"International *".Then refresh
Elevation 3 using the concatenation of String parsing query string, online has a variety of regular way to parse, remember too much, the temporary need to write, they are confused. Just remember one, use the regular. functionGetquerystringargs () {varSearch = (location.search.length > 0? location.search.slice (1): ""); varobj = {}; varreg =/([^?=]+) = ([^?=]*)/G; Search.replace (Reg,function(Match, $, $) { varName = decodeURIComponent
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.