First, let's release an address to you test.
Http://cnbruce.com/test/htmlpro/?name=cnbruce&email=cnbruce@126.com
1, the time is popular (maybe, because the most recently questioned people) is the URL address without any file name. For example, HTMLPRO /? In fact, this is related to the default file name of the server settings, such as index.htm, index.html, index.asp, etc., do not believe you try my friend (ASP).
http://www.windsn.com/blog/?viewtype =bycate&cateid=3
2, the files of this section are index.html, while the parameters are backed back, the page effect is like ASP generally extract information.
The following is the reprinted article (author Liu Wei) can explain something
Regular online friends are sure "
http://host/***.asp? Arg1 = * & arg2 = * "The URL (ie, URL) is not unfamiliar. The role of this type of URL is to pass the relevant information to the remote information by adding information content behind the URL. The web server, and returns the result to the client after proper processing, thereby reaching the purpose of web page interaction, and implements web content dynamism. (Note: Between the URL and the information content "?" Connection, each content field Between the character "&", the name / value of each field is represented as "name = value" form.) But through this way, the dynamic web page implemented in this way is required for server-side programming technology, recent author Using the browser supports DHTML and XML technology in making personal sites, through the continuous attempt, in this way, dynamic web pages in this manner in this way.
First, principle analysis
When the browser passes
HTTP: // RemoteHost / Program? QueryString When requested a web server, the web server analyzes the URL of the request address to store the QueryString string of "?" to the server-specific environment variable, and then call server-side programming execution. Environment, such as ASP (ActiveX Server Page), processes the request Program file.
Concrete calling What program execution environment is determined according to the setting of the server, if the requested document is an ASP type file, call the ASP, such as an ASPX type file, call ASP.NET. In the Program file, you can read environment variables by a certain method, such as an ASP file, you can read the environment variables via the Reques.QueryString data collection. After the programming execution environment is complete, return the result to the web server, the web server returns the result to the browser to achieve the purpose of the page content.
We can know if we use the above analysis.
httm? queryString mode When sending a request to the web server, the web server will return to the browser directly to the requested HTML page. At this time, we can use the locations.href attribute to obtain the URL string attached to the information content in the web page. After proper processing, you can get the attached information content field name and its value, and then through the DHTML feature supported by the browser. Processing, web page content dynamism can be achieved, thus reaching the purpose of web interaction on free homepage without supporting server-side programming technology.
We can also see that the purpose of reaching the web page dynamic interaction in this way is still not allowed to support the web server even in the browser, otherwise the browser will use "? QueryString" as part of the requested URL, thus appearing An error message that the web page cannot be viewed.
Second, the application example
--- A specific example source code with detailed comments will be given below. Note: queryString.js is a utility that can be referenced directly in the web, and then use the request ["name"] in the web page to obtain the information content input by the user. 1.QueryString.js source code
Function queryString () {// Construct parameter object and initializes var name, value, i; var str = location.href; // obtains the browser address bar URL string var Num = str.indexof ("?") str = STR. Substr (NUM 1); // Intercept "?" The parameter string var arrtmp = str.split ("&"); // Separate the parameters to form a parameter array for (i = 0; i
2.Sample.htm source code