URL 관련

2018. 3. 23. 14:57programming/javascript

URL이

https://www.google.co.kr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=html5 일 때,

 

 

window.location.href

// $(location).attr('href')

// https://www.google.co.kr/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=html5

 

window.location.protocol

// $(location).attr('protocol')

// https://

 

window.location.host

// $(location).attr('host')

// www.google.co.kr

 

window.location.pathname

// $(location).attr('pathname')

// /webhp

 

window.location.search

// $(location).attr('search')

// ?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8

 

window.location.hash

// #q=html5

 

window.location.origin

// https://www.google.co.kr

 

window.location.hostname

// www.google.co.kr

 

window.location.port

// "" (port number)

 

 

 

window.location.reload();    // webpage reloaded

window.location.toString();    // .href와 같은 결과가 나옴

window.location.replace("http://anysite.com");    // 현재 페이지를 대체함

// window.location.href = "http://anysite.com"; 과 같음

 

'programming > javascript' 카테고리의 다른 글

[jQuery] offset(), position()  (0) 2018.03.23
[jQuery] width(), height()  (0) 2018.03.23
lastIndexOf  (0) 2018.03.23
javascript 실행 순서  (0) 2018.03.23