养生 装修 购物 美食 感冒 便秘 营销 加盟 小吃 火锅 管理 创业 搭配 减肥 培训 旅游

js如何打开新页面

时间:2024-10-13 07:24:37

JS实现打开新页面的方法有多种,下面我们看来下有哪些?

方法/步骤

1、第一种:在当前页面打开新页面,具体代码如下(经过测试可用)<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title>JS实现打开新页面</title><scripttype="text/javascript">functionopen1(){window.location.href="http://www.baidu.com";}</script></head><body><ahref="javascript:void(0)"onclick="open1()">点击我,在当前页面打开指定的页面</a></body>

js如何打开新页面

js如何打开新页面

2、第二种:在新窗口中打开指定的页面,具体代码如下(经过测试可用)<!DOCTYPEh隋茚粟胫tmlPUBLIC"-//W3C/砖镑苣逢/DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/><title>JS实现打开新页面</title><scripttype="text/javascript">functionopen1(){window.location.href="http://www.baidu.com";}</script><scripttype="text/javascript">functionopen2(){window.open("http://www.baidu.com");}</script></head><body><ahref="javascript:void(0)"onclick="open1()">点击我,在当前页面打开指定的页面</a></br></br></br><ahref="javascript:void(0)"onclick="open2()">点击我,会在新窗口中打开指定的页面</a></body>

js如何打开新页面

js如何打开新页面

© 一点知识