프로젝트 관련 조사/웹
document.URL 과 location.href , location 비교
호레
2016. 6. 20. 12:27
반응형
출처: http://soke.tistory.com/14
alert(document.URL);
alert(document.location);
alert(document.location.href);
세가지 다 현재 URL 정보를 얻는스크립트입니다.
document.URL= "http://google.com";
document.location = "http://daum.net";
document.location.href = "http://naver.com";
document.URL에 "http://google.com"을 입력했는데요.
다시 alert(document.URL); 를 작성하여 현재 URL을 확인하여 보면 입력한 값과 다르게, 현재 URL이 나오는 것을 확인할 수 있습니다.
document.location = "http://daum.net";
document.location.href = "http://naver.com";
이 두개는 W3C에 따르면 동일합니다. 입력과 동시에 입력한 주소로 이동하게 됩니다.
반응형