location.href
location.replace()
location.assign()
location.href='URL'//或者
location.replace('URL')//或者
location.assign('URL')
<!DOCTYPE html><html><head><meta charset='UTF-8'></head><body><p>这是<i>location.href</i>方式的示例</p><button onclick='myFunc()'>点击这里</button><!--重定向到其他网页的脚本--><script> function myFunc() { window.location.href='https://www.jiangweishan.com'; } </script></body></html>
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
</head>
<body>
<p>这是<i>location.replace()</i>方式的示例</p>
<button onclick='myFunc()'>点击这里</button>
<!--重定向到其他网页的脚本-->
<script>
function myFunc() {
location.replace('https://www.jiangweishan.com');
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
</head>
<body>
<p>这是<i>location.assign()</i>方式的示例</p>
<button onclick='myFunc()'>点击这里</button>
<!--重定向到其他网页的脚本-->
<script>
function myFunc() {
location.assign('https://www.jiangweishan.com');
}
</script>
</body>
</html>
Google Chrome
Apple Safari
Firefox
Opera
Edge
联系客服