Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> JavaScript

วิธีเปลี่ยนเส้นทาง (Redirect) ไปยังเว็บเพจอื่นด้วย JavaScript


เพื่อเปลี่ยนเส้นทางไปยังเว็บเพจอื่นใน JavaScript ให้ใช้ window.location และระบุลิงก์เว็บไซต์ที่ต้องการเปลี่ยนเส้นทาง

<html> 
    <body> 
        <p>Redirecting to another website</p> 
        <script> 
            window.location = "https://www.qries.com"; 
        </script> 
        <p>This page will redirect to Qries.com</p> 
    </body> 
</html>