JS gets the url link string location.href

  • 2020-03-30 01:01:54
  • OfStack

Js gets the url link string: location.href

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

The location. The href. IndexOf ("?" ) -- -- -- -- -- - to get? The index of value.

Note: location.href here does not refer to the current address in the address bar, but to the actual address of the page.

In addition, some digression:

Get the IndexOf the position of the character in C#, also with IndexOf.

Sqlserver to get the index, is different:

The first:

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

The second:
Select * from dbo.users where patIndex('%2%',mainsubjects)> 0

I use the judgment column to determine whether the advertisement should display:

Only //www.jb51.net/codes/ directory contents will display ads:


if(location.href.indexOf("//www.jb51.net/codes/")>-1){ 
alert('ok'); 
}

Related articles: