在html中添加外部脚本js

第一个jswelcom.html

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
  <title>welcom~~~~~~~~~~~~~~</title>
  <script type="text/javascript" src="script07.js">
  </script>
 </head>
 <body bgcolor="#FFFFFF">
    <h2 align="center">
        <a href="nojsengine.html" id="redirect">welcom,touch me to the next page~//浏览器如果没有启用javascript就走这条连接,如果启用了则走外部脚本
        </a>
        <h3>
            hello
        </h3>
    </h2>
 </body>
</html>

 

第二个是外部脚本script07.js

window.onload = initAll;//界面加载完毕后触发initAll函数

function initAll()
{
    document.getElementById("redirect").onclick = initRedirect;//redirect元素被点击时触发initRedirect函数
}

function initRedirect()
{
    window.location = "script04.html";//设置新页面
    return false;//停止用户对点击的处理
}

 

第三个是要跳转到的script04.html

<!doctype html>
<html lang="en">
 <head>
  <meta charset="UTF-8">
  <meta name="Generator" content="EditPlus®">
  <meta name="Author" content="">
  <meta name="Keywords" content="">
  <meta name="Description" content="">
 
  <title>our site</title>
 </head>
 <body bgcolor="#FFFFFF">
    <h1>
    Welcom to our web site,which features lots of cutting-edge javascript
    </h1>
  
 </body>
</html>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值