Parameterized implementation of HTML page (imitation ASP)

Source: Internet
Author: User
Tags html page return window
Page

In the "Microcomputer World" saw an article " in HTML Web page skillfully using URL" to talk about how HTML pages like the ASP to accept the parameters of the problem, look like a thunderbolt general, Originally there are window.location.href such good dongdong, blame oneself weekdays bad good-looking material.
After reading, I immediately wrote the JS function to filter the corresponding parameters, plus the regular formula, really perfect. with DHTML and XML, a static site will live, it is amazing!

Javasctript implementation
function Request (querystring) {
var strhref=window.location.href;
var strparm;
if (Strhref.search (/\?/)!=-1) {
Strhref=strhref.substr (Strhref.search (/\?/) +1);
Strhref=strhref.split (/&/);
for (var icount = 0; icount<strhref.length; icount++) {
if (Strhref[icount].search ("^" +querystring+ "=")!=-1) {
Strparm=strhref[icount].substr (querystring.length+1)
}
}
return (Strparm);
}
}

If the lookup parameter is unsuccessful, the return value = "Undefined" can be judged again. This number only matches one of the last parameters found. (This method in February 2004 has been implemented, applied in my two HTML version of the Web site, is written on the Blogbus, hehe.) )



Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.