JavaScript gets the regular expression of the URL parameter (used to get a parameter value) _ Regular expression

Source: Internet
Author: User
Example:
JavaScript pass parameters (multiple)
var url = "B.aspx?txta=" +document.getelementbyid ("Txtname"). Value;
url = + "&txtb=" +document.getelementbyid ("Txtage"). Value;
window.open (URL, ' Xwindow ', ' Width=640,height=400,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes, Resizable=no,top=250,left=430 ');
B.aspx target page Get
Copy Code code as follows:

<scirpt language= ' javascirpt ' >
<!--
function GetStringValue ()
{
String.prototype.getQueryString = function (name)//name is the parameter name of the URL
{
var reg = new RegExp (^|&|\\?) + name + "= ([^&]*) (&|$)"), R;
if (R=this.match (reg)) return unescape (r[2]); return null;
};
The value of the parameter can be obtained directly by passing the parameter name
Alert (window.location.href.getQueryString ("Txta") +window.location.href.getquerystring ("TXTB"));
}
-->
</scirpt>

window.open and Window.location differences:
Window.Open is to open a new window
Window.location is to replace this page, that is, positioning
onclick= "javascript:window.location.href= ' xxxx.aspx ';"
JavaScript URL parameter read improved version
Http://www.jb51.net/article/17116.htm
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.