脚本说明:
第一步:把如下代码加入<head>区域中:
<script language="javascript">
<!–
var a = 21
function create() {
this.line =
}
function skrivut(formet) {
bild1 = formet.bilden.value;
bild2 = formet.bildtva.value;
kall1 = formet.srcen.value;
kall2 = formet.srctva.value;
bildnamn = formet.bildnmn.value;
widd = formet.widden.value;
hojd = formet.hojden.value;
line = new array()
for(var i=1; i<=a; i++) { line[i] = new create() }
line[1] = <html><head><title>code window</title></head><body bgcolor="#ffffff">
line[2] = <html><head><br><title>title of your page</title><p>
line[3] = <script language="javascript"><br><!–<br>/**luxiaoqing http://*.*.*/*/*.htm–/<br>browser = false ;<br>if(navigator.appname.indexof("netscape") != -1)<br>
line[5] = { if( (navigator.appversion.indexof("3.") != -1) || (navigator.appversion.indexof("4.") != -1) )<br>
line[6] = browser = true}<br>
line[7]=if(navigator.appversion.indexof("msie") != -1) { if( navigator.appversion.indexof("4.") != -1)<br>
line[8]=browser=true}<br>
line[9]=if ( browser == true) {<br>
line[10] = bild1+= new image();<br>
line[11] = bild1+.src = "+kall1+";<br>
line[12] = bild2+ = new image();<br>
line[13] = bild2+.src = "+kall2+";<br>}<p>
line[14] = function byt(place, imgname) {<br>
line[15] = if (browser == true) {<br>
line[16] = document[place].src =eval(imgname + ".src");<br>
line[17] = } }<br>
line[18] = //–><br>
line[19] = </script><p></head><br><body><p>here comes the link:<br>
line[20] = <a href=".html" onmouseover="byt(+bildnamn+,+bild2+)" onmouseout="byt(+bildnamn+,+bild1+)">
line[21] = <img src="+kall1+" name="+bildnamn+" height="+hojd+" width="+widd+" border="0"></a>
line[22] = <p></body></html><p><form><input type="button" value="关闭" onclick="self.close()"></form></body></html>
nyawin = window.open(,utskrift,toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=0,copyhistory=0,width=600,height=400)
nytt ()
}
g = 0
function nytt() {
g++
nyawin.document.writeln(line[g]);
if (g < (a+1)) nytt()
nyawin.document.close()
g = 0
}
browser = false ;
if(navigator.appname.indexof("netscape") != -1)
{ if( (navigator.appversion.indexof("3.") != -1) ||
(navigator.appversion.indexof("4.") != -1) )
{ browser = true;
fredrik= new image();
fredrik.src = "knapp1.gif";
sover = new image();
sover.src = "knapp2.gif";
} }
function byt(place, imgname) {
if (browser == true) {
document[place].src =eval(imgname + ".src");
} }
//–>
</script>
第二步:把如下代码加入<body>区域中:
<form>
图片1的名字:
<input type="text" name="bilden" class="pt9" value="mouseoutpic">
<br>
图片1的路径:
<input type="text" name="srcen" class="pt9" value="images/pic1.gif">
<br>
图片1的宽度:
<input type="text" name="widden" class="pt9" value="100">
<br>
图片1的高度:
<input type="text" name="hojden" class="pt9" value="50">
<p> 图片2的名字:
<input type="text" name="bildtva" class="pt9" value="mouseoverpic">
<br>
图片2的路径:
<input type="text" name="srctva" class="pt9" value="images/pic2.gif">
<br>
操作的名字 :
<input type="text" name="bildnmn" class="pt9" value="first_pic">
<br>
<input type="button" value="生成代码" onclick="skrivut(this.form)" class="pt9">
</form>
<p>
<p>说明:图片1==》mouse out时的图片,正常显示时。图片2==》mouse over时的图片。图片的名字和操作的名字可以随便取。有所区别即可。
<p>2个图片的尺寸必须一致才可以。