JS obtains the url link string location. href

Source: Internet
Author: User

JS obtains the url link string location. href

Sometimes we need to obtain the URL of the current webpage for our judgment. Generally, we use location. href to obtain the URL.

Js: location. href

 

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

 

Location. href. indexOf ("? ") ------ Get? Index value.

 

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

 

In addition, there are some additional questions:

 

In C #, the index of the character location is also obtained using IndexOf.

 

Obtaining indexes in SQL Server is different:

 

First:

 

Select * from dbo. users where CharIndex ('2', mainsubjects)> 0

 

Second:

Select * from dbo. users where patIndex ('% 100', mainsubjects)> 0

 

The Code is as follows:

If (location. href. indexOf ("http://www.jb51.net/codes/")>-1 ){

Alert ('OK ');

}

 

 

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.