html<body onload="党海正">怎么才能写到JS里面来调用

<!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>
<link href="danghaizheng.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="danghaizheng.js"></script>
<script type="text/javascript" src="dhzjs.js"></script>
<style type="text/css">
</style>
</head>
把下面body这里的写到一个JS或什么的把他在本页里哩写短一些
<body onload="MM_dragLayer('Layer2','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'');MM_dragLayer('Layer3','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'');MM_dragLayer('Layer4','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'')" onunload="MM_popupMsg('欢迎来到我的网站!')">

<div id="Layer1"><img src="images/1.jpg" width="714" height="108" /></div>
<div id="Layer2"><img src="images/1_01.gif" width="66" height="120" /></div>
<div id="Layer3"><img src="images/1_02.gif" width="439" height="120" /></div>
<div id="Layer4"><img src="images/1_03.gif" width="495" height="120" /></div>
</body>
</html> 

 

1. dhzjs.js中写入

 

function danghaizheng(){

MM_dragLayer('Layer2','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'');MM_dragLayer('Layer3','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'');MM_dragLayer('Layer4','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'')

}

 

html中的Body写法<body onload="danghaizheng()" onunload="MM_popupMsg('欢迎来到我的网站!')">

 

2. dhzjs.js中写入

 

function danghaizheng(){
MM_dragLayer('Layer2','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'');MM_dragLayer('Layer3','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'');MM_dragLayer('Layer4','',0,0,0,0,true,false,-1,-1,-1,-1,false,false,3,'',false,'')
}
function danghaizheng2(){
MM_popupMsg('欢迎来到我的网站!')
}

 

(1)html中的Body写法<body onload="danghaizheng();danghaizheng2()">

//同是加载两个JS(带弹窗)

(2)html中的Body写法<body onload="danghaizheng()" onunload="danghaizheng2()">

//先加载第一个再次刷新才回添加(弹窗)
标签: js

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.danghaizheng.com/?post=26

相关推荐

分享本文至:

你肿么看?

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。