window location

Estimated reading time: 1 minute

location

  • document.location
  • window.location
  • document.location===window.location

properties

name name name name name
protocol host hostname port pathname
href search hash username password
origin . . . .

href

document.location.href
//return: https://code4mk.org/js/search?test=mk

protocol

: before

document.location.protocol
//return: https:

host

: after

document.location.host
//return: code4mk.org

hostname

: after

document.location.hostname
//return: code4mk.org

port

document.location.port
//return:  :8080

pathname

document.location.pathname
// return:  /js/
document.location.search
// return:  ?test=mk

URLSearchParams

  • method lists
append()
delete()
entries()
forEach()
get()
getAll()
has()
keys()
set()
sort()
toString()
values()

location action

resource

location, js