The small collection of project experience (1) ___js gets the value from the previous page URL

Source: Internet
Author: User

Page Jump code: src= "addclffour.aspx?id=<%= request.querystring[" ID "]. ToString ()%> ">, via" request.querystring["ID". ToString () "Pass the parameter ID to addclffour, how do I get the ID value of the page from the Addclffour page?"

Here are three ways to simply describe how to implement JS to get the values from the previous page

1. The simplest method   

var wxjdid= <%=request.querystring["ID"]%>;

Get the ID by request.querystring.

2. With Addclffour backstage

public string Strwxjd; The background defines      the variable strwxjd=request.querystring["ID". ToString (); Receive the ID value passed over

JS to receive the ID on it.

var wxjdid= "<%= strwxjd%>";

Using a function in 3.js

function Getparameterbyname (name) {           name = Name.replace (/[\[]/, "\\\["). Replace (/[\]]/, "\\\]");           var regexs = "[\\?&]" + name + "= ([^&#]*)";            var regex = new RegExp (REGEXS);           var results = regex.exec (window.location.search);             if (results = = NULL)                    return null;            else                    return decodeURIComponent (Results[1].replace (/\+/g, ""));          }


JS in the Call Method Getparameterbyname () can.


For this issue, only the implementation of these three methods is verified for the time being. The problem is that the project needs to be produced, although very simple, I think it is necessary to tidy up a bit.

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.