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

方法1:使用location.href
语法:
location.href="URL"
示例
html>
<meta>
<p>这是<i>location.href</i>方式的示例</p>
<button>点击这里</button>
<!--重定向到其他网页的脚本-->
<script>
function myFunc() {
window.location.href="https://www.php.cn";
}
</script>

方法2:使用location.replace()
语法:
location.replace("URL")
示例:使用location.replace()方法跳转到其他网页
html>
<meta>
<p>这是<i>location.replace()</i>方式的示例</p><div class="aritcle_card flexRow artxards">
<div class="artcardd flexRow">
<a class="aritcle_card_img" rel="nofollow" href="/xiazai/skill13789" title="Exa JS Web Search SDK 用于 AI 应用程序"><img
src="https://img.php.cn/upload/skill/001/246/273/6adaf20d79f23518.jpg" alt="Exa JS Web Search SDK 用于 AI 应用程序" onerror="this.onerror='';this.src='/static/lhimages/moren/morentu.png'" ></a>
<div class="aritcle_card_info flexColumn">
<a rel="nofollow" href="/xiazai/skill13789" title="Exa JS Web Search SDK 用于 AI 应用程序" class="overflowclass">Exa JS Web Search SDK 用于 AI 应用程序</a>
<p class="overflowclass">exa-js 是 Exa 官方 JavaScript 软件开发工具包,Exa 是一个为 AI 工作流构建的网络搜索 API。它为代理提供了一种具体的方式来搜索网络、检索页面内容,并从代码中生成有来源的答案,而不是手动拼接原始 HTTP 调用。</p>
</div>
<a rel="nofollow" href="/xiazai/skill13789" title="Exa JS Web Search SDK 用于 AI 应用程序" class="aritcle_card_btn flexRow flexcenter"><b></b><span>下载</span>
</a>
</div>
</div>
<button>点击这里</button>
<!--重定向到其他网页的脚本-->
<script>
function myFunc() {
location.replace("https://www.php.cn");
}
</script>

方法3:使用location.assign()
语法:
location.assign("URL")
示例:使用location.assign()方法跳转到其他网页
html>
<meta>
<p>这是<i>location.assign()</i>方式的示例</p>
<button>点击这里</button>
<!--重定向到其他网页的脚本-->
<script>
function myFunc() {
location.assign("https://www.php.cn");
}
</script>

推荐教程:《JavaScript视频教程》










