js跳转到新页面的方法:1、使用location.href="新页面URL"来跳转;2、使用location.replace("新页面URL")来跳转;3、使用location.assign("新页面URL")来跳转。

方法1:使用location.href
语法:
location.href="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.php.cn";
}
</script>
</body>
</html>
方法2:使用location.replace()
语法:
location.replace("URL")示例:使用location.replace()方法跳转到其他网页
更新列表:1.求职列表后台审核了也显示不出来。2.点了职位后页面跳转不正确。3.首页点了人才简历页面你所在的位置标签不正确。4.点了职位后页面没有出现应聘此岗位标签。5.人才简历图片保存不下来。6.人才没有照片显示找不到路径的图片。7.首页资讯报错,and 附近有语法错误。8.资讯下面的热点资讯没有图片不显示无图出来。9.人才查看自己的职位列表表头显示不正确。10.人才的上传了图片,但是首页推荐信
0
<!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.php.cn");
}
</script>
</body>
</html>
方法3:使用location.assign()
语法:
location.assign("URL")示例:使用location.assign()方法跳转到其他网页
<!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.php.cn");
}
</script>
</body>
</html>
推荐教程:《JavaScript视频教程》
以上就是js怎么跳转到新页面?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号