HTML Location assign() 메서드는 문서 기록에서 현재 HTML 문서의 URL을 바꾸지 않고 새 HTML 문서를 로드합니다.
구문
다음은 구문입니다 -
location.assign(URL)
HTML Location assign() 메서드의 예를 살펴보겠습니다-
예시
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
height: 100vh;
background: linear-gradient(62deg, #FBAB7E 0%, #F7CE68 100%) no-repeat;
text-align: center;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 20px;
width: 330px;
display: block;
color: #fff;
outline: none;
cursor: pointer;
margin: 1rem auto;
}
</style>
<body>
<h1>HTML Location assign() Method Demo</h1>
<button class="btn" onclick="display()">Load Tutorialspoint</button>
<script>
function display() {
location.assign("https://tutorialspoint.com/");
}
</script>
</body>
</html> 출력

"튜토리얼 포인트 로드를 클릭합니다. ” 버튼을 눌러 현재 문서에 tutorialspoint 문서를 로드합니다-
