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 ');
}