HTML DOM Location reload() 메서드는 현재 문서를 다시 렌더링하는 데 사용됩니다. 브라우저의 새로고침 버튼과 동일한 기능을 제공합니다.
구문
다음은 구문입니다 -
location.reload(forceGetParameter)
매개변수
여기 "forceGetParameter" 다음과 같을 수 있습니다 -
| forceGetParameter | 세부정보 |
|---|---|
| 사실 | 현재 문서가 서버에서 다시 로드됨을 정의합니다. |
| 거짓 | 현재 문서가 브라우저 캐시에서 다시 로드되도록 정의합니다. |
예시
Location reload()의 예를 살펴보겠습니다. 속성 -
<!DOCTYPE html>
<html>
<head>
<title>Location reload()</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>Location-reload( )</legend>
<label for="urlSelect">Email: </label>
<input type="email" id="emailSelect"><br>
<label for="urlSelect">Password: </label>
<input type="password" id="passSelect"><br>
<input type="button" onclick="doReload()" value="Reload">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var emailSelect = document.getElementById("emailSelect");
var passSelect = document.getElementById("passSelect");
divDisplay.textContent = 'Do not reload, all the details will be lost';
function doReload(){
alert('Page reloaded, all the details are lost');
location.reload();
}
</script>
</body>
</html> 출력
이것은 다음과 같은 출력을 생성합니다 -
'새로고침'을 클릭하기 전에 버튼 -

'새로고침' 클릭 세부 정보를 채운 후 버튼 -
