JavaScript How to redirect a page
摘要: In JavaScript, we can use either location.replace() or location.href to redirect a page. Normally, we use location.replace() to simulate an HTTP redirect.
In JavaScript, we can use either location.replace() or location.href to redirect a page. Normally, we use location.replace() to simulate an HTTP redirect.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <body> <h1>JavaScript - How to redirect a page</h1> <h3>1. location.replace</h3> <button onclick="httpRedirect()">location.replace</button> <h3>2. location.href</h3> <button onclick="mouseClick()">location.href</button> <script> // Simulate an HTTP redirect function httpRedirect() { location.replace("https://www.mkyong.com") // Simulate a mouse click function mouseClick() { location.href("https://www.yahoo.com") </script> </body> </html>
上一篇:
Log4j 2 java.lang.NoClassDefFoundError: com/lmax/disruptor/EventTranslatorVararg
下一篇: Apache Log4j 2 Tutorials
下一篇: Apache Log4j 2 Tutorials