Copy Code code as follows:
function request (Strparame) {
var args = new Object ();
var query = location.search.substring (1);
var pairs = Query.split ("&"); Break at Ampersand
for (var i = 0; i var pos = pairs[i].indexof (' = ');
if
Javascript
There are generally two ways to submit data for a page: Get,post. Post is the so-called form submission, which uses views, and get is submitted by URL.
Get methods generally use background code (such as asp,asp.net) to obtain parameters,
jquery gets the URL parameter and turns the code, first constructs a regular expression object containing the target parameter, matches the target parameter and returns the parameter value
The code is as follows:
Test
The code is very simple, the main idea is to parse the URL parameters to JS object, and then do add, delete, change, check the operation is very convenient ~, take notes here.
Copy Code code as follows:
var lg= (function (LG) {
var
/** This function parses ampersand-separated name=value argument pairs from* The query string of the URL. It stores the Name=value pairs in* Properties of an object and returns that object. Use it as this:** var args = Getargs (); Parse args from
Use php to analyze the URL to get the file name, directory path, and other data. The principle is to use the PHP explode function to separate strings. To be as efficient as possible, retrieve the file extension from a standard url, and then extend
Php obtains the summary of url parameter program code. The parse_url function first describes the parse_url function. The official solution is mixedparse_url (string $ url [, int $ component-1]). This function parses a URL and returns an associated
Many functions can be used to obtain url addresses in php. The global variable server provides me with many methods. Let's take a look.
Common functions
The Code is as follows:
Copy code
// Obtain the domain name or host
To be as efficient as possible, retrieve the file extension from a standard url, and then extend the code to get other data, such as directory path, the principle is to use the explode function of PHP to separate strings.Example:
This article mainly introduces how to obtain url parameters through js analysis url? In the previous section, # And later sections, you can check the code. The main idea is to parse url parameters into js objects, it is convenient to add, delete,
This article is to introduce us when we submit a form if the form uses a Get method, and then we use get to get to the will be garbled, let me see how to solve this problem.
Originally intended to use this
The code is as follows
Copy
PHP Get file name
Copy CodeThe code is as follows:
function Retrieve ($url)
{
Preg_match ('/\/([^\/]+\.[ a-z]+) [^\/]*$/', $url, $match);
return $match [1];
}
PHP Get file name extension
Copy CodeThe code is as follows:
function Getext ($url)
{
The complete URL consists of the following parts:Scheme: // host: Port/path? Query # Fragment
Scheme = communication protocol (Common HTTP, FTP, Maito, etc)Host = host (domain name or IP address)Port = port numberPath = path
Query = QueryOptional.
In the project, you need to obtain the get parameter through JS, find the following plug-in on the Internet:
For example, your url is:Http://www.xxx.com/index.php? Test = 1 & KK = 2
If you want to obtain test, you can introduce the
Obtain URL parameters using regular expressions
1. method for obtaining a single parameter
// Obtain the function getquerystring (name) {var Reg = new Regexp ("(^ | &)" + name + "= ([^ &] *) using the URL parameter. (& | $) "); var r = Window.
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.