HTML.CSS.JS/JS

[JS] 새로고침, 취소 location.reload

congs 2023. 4. 18. 09:17

1. 버튼에서 바로 새로고침하는 경우

: window.location.reload(); 

 
<button type="button" onclick="window.location.reload();">다시하기</button>
 

 

2. function함수안에서 사용하는 경우

: location.reload(); 

 
<button type="button" onclick="reset();">다시하기</button>
 
//버튼 : 다시하기
function reset(){
      location.reload();
}