JS get URL link string location.href_ basics

Source: Internet
Author: User
JS get URL link string: location.href

It can be intercepted to obtain the transmitted parameters, which are commonly used as follows:

Location.href.indexOf ("?") ------Get it? The index value.

Note: The location.href here is not the address in the Address bar now, but the actual address of the page.

In addition, some digression:

The index in C # that gets the location of the character is also obtained by indexof.

Getting an index in SQL Server is different:

First type:

SELECT * from Dbo.users where CharIndex (' 2 ', mainsubjects) >0

The second type:
SELECT * from Dbo.users where PatIndex ('%2% ', mainsubjects) >0

I use the Judge column to determine whether the advertisement should be displayed:

Only the contents of the http://www.jb51.net/codes/directory display ads:

Copy Code code as follows:

if (Location.href.indexOf ("http://www.jb51.net/codes/") >-1) {
Alert (' OK ');
}

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.