Web/Javascript
[Javascript] 현재 페이지 이름 가져오기
saltdoll
2018. 1. 10. 08:35
반응형
Javascript를 통해서, 현제 페이지 이름 가져오기,
http://test.com/a.html&a=11 => a.html를 가져온다.
https://developer.mozilla.org/en/DOM/window.location
alert(location.pathname)
If you don't want the leading slash, you can strip it out.
location.pathname.substring(1)
참조: Get the page file name from the address bar
페이지 이름 가져오기
var path = window.location.pathname;
var page = path.split("/").pop();
console.log( page );
참고: https://stackoverflow.com/questions/16611497/how-can-i-get-the-name-of-an-html-page-in-javascript
반응형