js如何打开新页面

 时间:2024-10-12 07:12:34

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

js如何打开新页面
js如何打开新页面

2、第二种:在新窗口中打开指定的页面,具体代码如下(经过测试可用)<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/><title>JS实现打开新页面</title><script type="text/javascript">function open1(){window.location.href="http://www.baidu.com";}</script><script type="text/javascript">function open2(){window.open("http://www.baidu.com");}</script></head><body><a href="javascript:void(0)" onclick="open1()">点击我,在当前页面打开指定的页面</a></br></br></br><a href="javascript:void(0)" onclick="open2()">点击我,会在新窗口中打开指定的页面</a></body>

js如何打开新页面
js如何打开新页面
  • 谷歌浏览器怎么设置网页大小
  • asp获取当前时间
  • jquery怎么显示div内的内容
  • c#中 this.Invoke 参数计数不匹配
  • 热门搜索
    年俗年韵年文化手抄报 爱祖国手抄报资料 法制安全手抄报资料 海洋的手抄报 争做文明学生手抄报 手抄报版面设计图片 手抄报怎么写 小学生行为规范手抄报 保护环境手抄报素材 语文天地手抄报内容