728x90
javascript - base Url 추출
var getUrl = window.location;
//http://www.naver.com/test
console.log("전체주소 : " + getUrl);
var baseUrl = getUrl .protocol + "//" + getUrl.host + "/" + getUrl.pathname.split('/')[1];
//http:
console.log("getUrl .protocol : " + getUrl .protocol);
//www.naver.com
console.log("getUrl.host : " + getUrl.host);
//test
console.log("getUrl.pathname.split('/')[1] : " + getUrl.pathname.split('/')[1]);
//http://www.naver.com/test
console.log("baseUrl : " + baseUrl);
https://stackoverflow.com/questions/25203124/how-to-get-base-url-with-jquery-or-javascript
728x90
반응형
'개발' 카테고리의 다른 글
비밀번호 보기 / 숨기기 기능 구현 (0) | 2020.08.06 |
---|---|
[SNS 로그인] 구글 회원가입, 로그인 (버튼 변경 가능) (0) | 2020.07.31 |
[linux] chmod 하위 폴더 권한 적용 (0) | 2020.07.23 |
[javascript] toogle 버튼 만들기 (0) | 2020.07.23 |
[문자열 변환] MD5 변환기 (0) | 2020.07.22 |