Js to get the address bar? Method _ javascript tips for parameters after question mark

Source: Internet
Author: User
This article introduces how to get the address bar of js? For more information about the parameter method after question mark, see the following code:


$ (Document). ready (function (){
Var url = window. location. search;
If (url. indexOf ("? ")! =-1 ){
Var str = url. substr (1)
Strs = str. split ("&");
For (I = 0; I <strs. length; I ++ ){
Alert (strs. length );
Alert (strs [I]. split ("=") [0]);
Alert (strs [I]. split ("=") [1]);
Alert (strs [I]. split ("=") [0], '=', strs [I]. split ("=") [1],'
');
}
}
})


For example, the above address, strs. the length is: 2, strs [0]. split ("=") [0] value: tn; strs [0]. the value of split ("=") [1] is: list; strs [1]. the value of split ("=") [0] is: word; strs [1]. the value of split ("=") [1] is: liulan

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.