JavaScript难道不能这样子莫?

来源:百度知道 编辑:UC知道 时间:2024/09/28 07:17:04
下面是一个简单的页面,有两段JavaScript程序,显示时间的和图片漂浮,但是两个同时写进去的话,有一个就不正常了。加入单独一个程序的话,就没有问题。想问问大侠,什么问题??????

<!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=gb2312" />
<title>无标题文档</title>

<style type="text/css">
<!--
#Layer1 a,#Layer1 a:visited{
text-decoration:none;
border-style:none;}
img{border:0}
INPUT {
font-size: 50px;
color: #CC0000;
border-style:none
}
#Layer1 {
position:absolute;
width:100px;
height:1

楼主页面上有两个 body标签,而且两断的js代码应该是拷贝来的吧!因为你第一指定了window.onload=init;这样加载完成后会调用 init()函数,但你在body里面又写里一句:<BODY onload="disptime()">这等于把window.onload的事件触发代码复写了,这样,你两段代码就只能运行一次了,去掉第二个body标签并同时修改 window.onload事件触发函数,同时加载两个函数就可以里,下面是全部代码,测试没有问题,期待给分!

<!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=gb2312" />
<title>无标题文档</title>

<style type="text/css">
<!--
#Layer1 a,#Layer1 a:visited{
text-decoration:none;
border-style:none;}
img{border:0}