location.href = "https://example.com";
// 또는 window.location.href = "https://example.com";
<button type="button" onclick="location.href='https://example.com'">이동하기</button>
<!-- 또는 -->
<button type="button" onclick="window.location.href='https://example.com'">이동하기</button>
<button type="button" id="href-btn">이동하기</button>

<script>
    const hrefBtn = document.getElementById("href-btn");
    hrefBtn.addEventListener("click", () => {
        location.href = "https://example.com";
        // 또는 window.location.href = "https://example.com";
    });
</script>
location.replace("https://example.com");
// 또는 window.location.replace("https://example.com");
<button type="button" onclick="location.replace('https://example.com')">이동하기</button>
<!-- 또는 -->
<button type="button" onclick="window.location.replace('https://example.com')">이동하기</button>
<button type="button" id="href-btn">이동하기</button>

<script>
    const hrefBtn = document.getElementById("href-btn");
    hrefBtn.addEventListener("click", () => {
        location.replace("https://example.com");
        // 또는 window.location.replace("https://example.com");
    });
</script>
window.open("https://example.com");
<button type="button" onclick="window.open('https://example.com')">이동하기</button>
<button type="button" id="open-window-btn">이동하기</button>

<script>
    const openWindowBtn = document.getElementById("open-window-btn");
    openWindowBtn.addEventListener("click", () => {
        window.open("https://example.com");
    });
</script>
location.reload();
// 또는 window.location.reload();
<button type="button" onclick="location.reload()">새로고침하기</button>
<!-- 또는 -->
<button type="button" onclick="window.location.reload()">새로고침하기</button>
<button type="button" id="reload-btn">새로고침하기</button>

<script>
    const reloadBtn = document.getElementById("reload-btn");
    reloadBtn.addEventListener("click", () => {
        location.reload();
        // 또는 window.location.reload();
    });
</script>
예 - URL에서 해시(Hash): #section-2
<section id="section-1">
    <h2>섹션 1</h2>
</section>
<section id="section-2">
    <h2>섹션 2</h2>
</section>
<section id="section-3">
    <h2>섹션 3</h2>
</section>
location.hash = "example-1";
// 또는 location.hash = "example-1";
<button type="button" onclick="location.hash='example-1'">해시 설정하기</button>
<!-- 또는 -->
<button type="button" onclick="window.location.hash='example-1'">해시 설정하기</button>
<button type="button" id="hash-btn">해시 설정하기</button>

<script>
    const hashBtn = document.getElementById("hash-btn");
    hashBtn.addEventListener("click", () => {
        location.hash = "example-1";
        // 또는 window.location.hash = "example-1";
    });
</script>
history.back();
// 또는 window.history.back();
<button type="button" onclick="history.back()">이전 페이지로 이동하기</button>
<!-- 또는 -->
<button type="button" onclick="window.history.back()">이전 페이지로 이동하기</button>
<button type="button" id="back-btn">이전 페이지로 이동하기</button>

<script>
    const backBtn = document.getElementById("back-btn");
    
    backBtn.addEventListener("click", () => {
        history.back();
        // 또는 window.history.back();
    });
</script>
history.forward();
// 또는 window.history.forward();
<button type="button" onclick="history.forward()">다음 페이지로 이동하기</button>
<!-- 또는 -->
<button type="button" onclick="window.history.forward()">다음 페이지로 이동하기</button>
<button type="button" id="forward-btn">다음 페이지로 이동하기</button>

<script>
    const forwardBtn = document.getElementById("forward-btn");
    
    forwardBtn.addEventListener("click", () => {
        history.forward();
        // 또는 window.history.forward();
    });
</script>