js入门例子小结3

来源:互联网 发布:软件著作权登记说明书 编辑:程序博客网 时间:2024/06/10 19:38

感谢张龙的视频


js17.html


<script type="text/javascript">//采用confirm if(confirm("你确定继续?")){window.location.href="http://www.google.com";}else {alert("bye");}</script>

js19.html


<body><!--  按钮的单击事件绑定到clickHandler函数--><input type= "button" value="click me"id = "button1"><script type="text/javascript">var v = document.getElementById("button1");v.onclick = clickHandler;function clickHandler(){alert("hai");}</script></body>

js20.html和js21.html实现来回页面的切换

js20.html

<body> <a href="js21.html">click me </a>   </body>

js21.html


<body><a href="#" onclick="window.history.back()"return false>return</a></body>



js22.html


<script type="text/javascript">//五秒后自动转向别的页面var timerId;function onLoad(){timerId = setInterval('setNum()', 1000);}</script> </head>    <body onload="onLoad();">  <script type="text/javascript">var sec = 5;function setNum(){if(sec > 0){document.getElementById("num").innerHTML = sec--;}else {clearInterval(timerId);location.href = "http://www.google.com";}}</script>五秒钟后前往<br><font id = "num" size="7">5</font>  </body></html>




0 0
原创粉丝点击