본문 바로가기
개발일기/JavaScript

[JQuery] [JavaScript] 현재 페이지 URL 찾기

by dori625 2021. 1. 27.

javascript

window.location.host          #returns host
window.location.hostname      #returns hostname
window.location.pathname      #return pathname
window.location.href          #returns full current url
window.location.port          #returns the port
window.location.protocol      #returns the protocol


jQuery

$(location).attr('host');        #returns host
$(location).attr('hostname');    #returns hostname
$(location).attr('pathname');    #returns pathname
$(location).attr('href');        #returns href
$(location).attr('port');        #returns port
$(location).attr('protocol');    #returns protocol