动态按钮生成器(下)
2001-08-29 11:05:27 来源:WEB开发网核心提示:由于内容超长,只好分2次贴出,动态按钮生成器(下),以下为下半部分:Images.length+=1;for(var b=Images.options.length-1;b>g;b--){Images.options[b].text=Images.options[b-1].text;}Images.options
由于内容超长,只好分2次贴出,以下为下半部分:
Images.length+=1;for(var b=Images.options.length-1;b>g;b--)
{Images.options[b].text=Images.options[b-1].text;}Images.options[g+1].text=Imagi[g+1].Name;CleanBoxes(window.document.mouSEOverForm);}}}else
{if(Images.length!=0)
{var g=-1;var r=no_of_images;Imagi[r]=new ImageObject(Imagi[r-1].Name,Imagi[r-1].OffSrcPRo,Imagi[r-1].OffSrc,Imagi[r-1].OnSrcPro,Imagi[r-1].OnSrc,Imagi[r-1].Width,Imagi[r-1].Height,Imagi[r-1].Alt,Imagi[r-1].Border,Imagi[r-1].URL,Imagi[r-1].LinkTarget);for(var p=Imagi.length-2;p>g;p--)
{Imagi[p].Name=Imagi[p-1].Name;Imagi[p].OffSrcPro=Imagi[p-1].OffSrcPro;Imagi[p].OffSrc=Imagi[p-1].OffSrc;Imagi[p].OnSrcPro=Imagi[p-1].OnSrcPro;Imagi[p].OnSrc=Imagi[p-1].OnSrc;Imagi[p].Width=Imagi[p-1].Width;Imagi[p].Height=Imagi[p-1].Height;Imagi[p].Alt=Imagi[p-1].Alt;Imagi[p].Border=Imagi[p-1].Border;Imagi[p].URL=Imagi[p-1].URL;Imagi[p].LinkTarget=Imagi[p-1].LinkTarget;}
Imagi[g+1].URL=URLBox.value;Imagi[g+1].LinkTarget=TargetBox.value;Imagi[g+1].Name=NameBox.value;Imagi[g+1].OffSrcPro=HeadSrc1.value;Imagi[g+1].OnSrcPro=HeadSrc2.value;Imagi[g+1].OffSrc=SrcBox1.value;Imagi[g+1].OnSrc=SrcBox2.value;Imagi[g+1].Width=WidthBox.value;Imagi[g+1].Height=HeightBox.value;Imagi[g+1].Alt=AltBox.value;Imagi[g+1].Border=BorderBox.value;no_of_images++;
Images.length+=1;for(var b=Images.options.length-1;b>g;b--)
{Images.options[b].text=Images.options[b-1].text;}Images.options[g+1].text=Imagi[g+1].Name;CleanBoxes(window.document.mouseOverForm);}else
alert("缺少项目!")
}}}function CheckIt(array,string){if(array==null||array=="")
variable="";else
variable=string+array+"\"";return variable;}function generateIt() {if (document.mouseOverForm.Images.length != 0) {HeadCode = "<SCRipT LANGUAGE=\"javascript\">\r" + "<" + "!-" + "-Hide\r\r";HeadCode += "//http://www.njcatv.net/Javascript/dai5.htm\r\r";HeadCode += "function isCompatible()\r" + "{\r" + "var BrowserName=navigator.appName;\r" + "var BrowserVer=parseInt(navigator.appVersion);\r" + "var Compatible=(BrowserName==\"Netscape\"&&BrowserVer==3)||(BrowserName==\"Netscape\"||BrowserVer==4)||(BrowserName==\"Microsoft Internet Explorer\"||BrowserVer==4)\r" + "return Compatible;\r" + "}\r\r";HeadCode += "function flipIt(img,tothis)\r" + "{\r" + "if(isCompatible())\r" + "{\r" + "img.src=tothis.src;\r" + "}\r" + "}\r\r";BodyCode = "";for (var count = 0; count < Imagi.length; count++) {var xName = Imagi[count].Name;var xNameOff = Imagi[count].OffSrcPro + Imagi[count].OffSrc;var xNameOn = Imagi[count].OnSrcPro + Imagi[count].OnSrc;var Target = CheckIt(Imagi[count].LinkTarget, "TARGET=\"");var Border=CheckIt(Imagi[count].Border," BORDER=\"");var Alt = CheckIt(Imagi[count].Alt, "ALT=\"");var Width=CheckIt(Imagi[count].Width," WIDTH=\"");var Height = CheckIt(Imagi[count].Height, "HEIGHT=\"");var MouseOver="onMouseOver=\"flipIt(document." + xName + "," + xName + "On);\"";
var MouseOut="onMouseOut=\"flipIt(document." + xName + "," + xName + "Off);\"";
HeadCode+=xName+"Off = new Image();\r";HeadCode+=xName+"Off.src = "+"\"" + xNameOff + "\";"+"\r";HeadCode+=xName+"On = new Image();\r";HeadCode+=xName+"On.src = "+"\"" + xNameOn + "\";"+"\r";BodyCode+="<A HREF=\""+ Imagi[count].URL + "\""+Target+" "+MouseOver+" "+MouseOut+"><IMG SRC=\"" + xNameOff + "\" NAME=\"" + xName + "\""+Border+Alt+Width+Height+"></A>\r\r";}HeadCode+="\r/"+"/End Hide-"+"->\r";Emulate=window.open("","CodeWindow","width=640,height=420,status=yes,resizable=yes,scrollbars=yes");Emulate.document.clear();Emulate.document.write('<html><head><title>Code generated</title></head><body bgcolor="#ffffff" text="#000000" link="#000099" vlink="#663366" alink="#ff0000">');Emulate.document.write("<br><br><center><font face=\"宋体\">如下代码拷贝到<font color=\"red\">HEAD</font>标签间</font></center><form name=\"genCode\"><center><textarea cols=55 rows=16 name=\"Head\" wrap=\"Virtual\"></textarea><p><font face=\"宋体\">如下代码拷贝到<font color=\"red\">BODY </font>标签间</font><p><textarea cols=55 rows=16 name=\"Body\" wrap=\"Virtual\"></textarea><p><input type=\"Button\" value=\"Close \" onClick=\"window.close();\"></center></form><br>");Emulate.document.write('<br><hr width=610 noshade></body></html>');
Emulate.document.genCode.Head.value=HeadCode;Emulate.document.genCode.Body.value=BodyCode;Emulate.document.close();}else
alert("You haven't made anything yet");
}
//End Hide-->
</script><title>New Page 1</title></head><body><table width=610 cellpadding=0 cellspacing=0 border=0><tr><td align=center><form name=mouseOverForm><table cellspacing=0 cellpadding=0 border=1 width=580><tr><td bgcolor=royalblue><font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>Images</b></font></td><td bgcolor=#ffcf1f rowspan=6></td><td rowspan=6 valign=top><table cellspacing=0 cellpadding=0 border=0><tr><td bgcolor=royalblue><font face="verdana, arial, helvetica" color=#ffffff size=-1><b>MouseOut Image Source</b></font></td></tr><tr><td><table><tr><td><select name=Header1 onChange="headerSelect(document.mouseOverForm.Header1, document.mouseOverForm.HeadSrc1);"><option>None</option><option>file:///</option><option>http://</option></select><br><input type=Text value= name=HeadSrc1 size=8><input type=Text value= name=SrcBox1 size=22 onBlur=CheckAndChange(1);><input type=Button value="Hard Drive" name=SrcBox1but onClick=PopDrive(1);><br><br></td></tr></table></td></tr><tr><td bgcolor=royalblue><font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>MouseOver Image Source</b></font></td></tr><tr><td><table><tr><td><select name=Header2 onChange="headerSelect(document.mouseOverForm.Header2, document.mouseOverForm.HeadSrc2);"> <option>None</option> <option>file:///</option> <option>http://</option> </select><br> <input type=Text value= name=HeadSrc2 size=8> <input type=Text value= name=SrcBox2 size=22 onBlur=CheckAndChange(2);> <input type=Button value="Hard Drive" name=SrcBox2but onClick=PopDrive(2);> <br><br> </td> </tr> </table> </td> </tr> <tr> <td bgcolor=royalblue> <font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>Control Panel</b></font> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=0 border=0> <tr> <td> <input type=Button value="Add image" name=Insert onClick=CheckAndChange(1);CheckAndChange(2);insertItem();> </td> <td> <input type=Button value="Add image below" name=InsertBelow onClick=InsertBelow();> </td> <td> </tr> <tr> <td> <input type=Button value="Update image" name=Update onClick=UpdateOption();> </td> <td> <input type=Button value="Remove image" name=Remove onClick=removeIt();> </td> </tr> <tr> <td> <input type=Button value="Clean fields" name=Clean onClick=CleanBoxes(window.document.mouseOverForm)> </td> <td> <input type=Button value="Generate Code!" name=Generate onClick=generateIt();> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <select width=240 size=6 onChange=checkAndShow() name=Images> <option>Please be patient while loading </select> </td> </tr> </table> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Create the image as a link to: </b></font><br> <input type=Text value=http:// name=URLBox size=34> </td> </tr> </table> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Target</b><font face="helvetica, arial, sans serif" size=-2><b> (for frames only)</b></font><b>:</b></font> <br> <input type=Text value= name=TargetBox size=25> </td> </tr> </table> </td> </tr> <tr> <td bgcolor=royalblue> <font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>Attributes</b></font> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Width:</b></font> </td> <td> <input type=Text value= name=WidthBox size=4 onBlur=isDigit(this)> </td> <td> <font face="helvetica, arial, sans serif" size=-1><b>Name:</b></font> </td> <td> <input type=Text value= name=NameBox size=10> </td> </tr> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Height:</b></font> </td> <td> <input type=Text value= name=HeightBox size=4 onBlur=isDigit(this)> </td> <td> <font face="helvetica, arial, sans serif" size=-1><b>Alt:</b></font> </td> <td> <input type=Text value= name=AltBox size=10> </td> </tr> <tr> <td colspan=2 align=right> <font face="helvetica, arial, sans serif" size=-1><b>Border:</b></font> </td> <td colspan=2> <input type=Text value= name=BorderBox size=5 onBlur=isDigit(this)><p> </td> </tr> </table> </td> </tr> </table> </td> </form> </tr></table> <select> <option>None%3</body></html>
Images.length+=1;for(var b=Images.options.length-1;b>g;b--)
{Images.options[b].text=Images.options[b-1].text;}Images.options[g+1].text=Imagi[g+1].Name;CleanBoxes(window.document.mouSEOverForm);}}}else
{if(Images.length!=0)
{var g=-1;var r=no_of_images;Imagi[r]=new ImageObject(Imagi[r-1].Name,Imagi[r-1].OffSrcPRo,Imagi[r-1].OffSrc,Imagi[r-1].OnSrcPro,Imagi[r-1].OnSrc,Imagi[r-1].Width,Imagi[r-1].Height,Imagi[r-1].Alt,Imagi[r-1].Border,Imagi[r-1].URL,Imagi[r-1].LinkTarget);for(var p=Imagi.length-2;p>g;p--)
{Imagi[p].Name=Imagi[p-1].Name;Imagi[p].OffSrcPro=Imagi[p-1].OffSrcPro;Imagi[p].OffSrc=Imagi[p-1].OffSrc;Imagi[p].OnSrcPro=Imagi[p-1].OnSrcPro;Imagi[p].OnSrc=Imagi[p-1].OnSrc;Imagi[p].Width=Imagi[p-1].Width;Imagi[p].Height=Imagi[p-1].Height;Imagi[p].Alt=Imagi[p-1].Alt;Imagi[p].Border=Imagi[p-1].Border;Imagi[p].URL=Imagi[p-1].URL;Imagi[p].LinkTarget=Imagi[p-1].LinkTarget;}
Imagi[g+1].URL=URLBox.value;Imagi[g+1].LinkTarget=TargetBox.value;Imagi[g+1].Name=NameBox.value;Imagi[g+1].OffSrcPro=HeadSrc1.value;Imagi[g+1].OnSrcPro=HeadSrc2.value;Imagi[g+1].OffSrc=SrcBox1.value;Imagi[g+1].OnSrc=SrcBox2.value;Imagi[g+1].Width=WidthBox.value;Imagi[g+1].Height=HeightBox.value;Imagi[g+1].Alt=AltBox.value;Imagi[g+1].Border=BorderBox.value;no_of_images++;
Images.length+=1;for(var b=Images.options.length-1;b>g;b--)
{Images.options[b].text=Images.options[b-1].text;}Images.options[g+1].text=Imagi[g+1].Name;CleanBoxes(window.document.mouseOverForm);}else
alert("缺少项目!")
}}}function CheckIt(array,string){if(array==null||array=="")
variable="";else
variable=string+array+"\"";return variable;}function generateIt() {if (document.mouseOverForm.Images.length != 0) {HeadCode = "<SCRipT LANGUAGE=\"javascript\">\r" + "<" + "!-" + "-Hide\r\r";HeadCode += "//http://www.njcatv.net/Javascript/dai5.htm\r\r";HeadCode += "function isCompatible()\r" + "{\r" + "var BrowserName=navigator.appName;\r" + "var BrowserVer=parseInt(navigator.appVersion);\r" + "var Compatible=(BrowserName==\"Netscape\"&&BrowserVer==3)||(BrowserName==\"Netscape\"||BrowserVer==4)||(BrowserName==\"Microsoft Internet Explorer\"||BrowserVer==4)\r" + "return Compatible;\r" + "}\r\r";HeadCode += "function flipIt(img,tothis)\r" + "{\r" + "if(isCompatible())\r" + "{\r" + "img.src=tothis.src;\r" + "}\r" + "}\r\r";BodyCode = "";for (var count = 0; count < Imagi.length; count++) {var xName = Imagi[count].Name;var xNameOff = Imagi[count].OffSrcPro + Imagi[count].OffSrc;var xNameOn = Imagi[count].OnSrcPro + Imagi[count].OnSrc;var Target = CheckIt(Imagi[count].LinkTarget, "TARGET=\"");var Border=CheckIt(Imagi[count].Border," BORDER=\"");var Alt = CheckIt(Imagi[count].Alt, "ALT=\"");var Width=CheckIt(Imagi[count].Width," WIDTH=\"");var Height = CheckIt(Imagi[count].Height, "HEIGHT=\"");var MouseOver="onMouseOver=\"flipIt(document." + xName + "," + xName + "On);\"";
var MouseOut="onMouseOut=\"flipIt(document." + xName + "," + xName + "Off);\"";
HeadCode+=xName+"Off = new Image();\r";HeadCode+=xName+"Off.src = "+"\"" + xNameOff + "\";"+"\r";HeadCode+=xName+"On = new Image();\r";HeadCode+=xName+"On.src = "+"\"" + xNameOn + "\";"+"\r";BodyCode+="<A HREF=\""+ Imagi[count].URL + "\""+Target+" "+MouseOver+" "+MouseOut+"><IMG SRC=\"" + xNameOff + "\" NAME=\"" + xName + "\""+Border+Alt+Width+Height+"></A>\r\r";}HeadCode+="\r/"+"/End Hide-"+"->\r";Emulate=window.open("","CodeWindow","width=640,height=420,status=yes,resizable=yes,scrollbars=yes");Emulate.document.clear();Emulate.document.write('<html><head><title>Code generated</title></head><body bgcolor="#ffffff" text="#000000" link="#000099" vlink="#663366" alink="#ff0000">');Emulate.document.write("<br><br><center><font face=\"宋体\">如下代码拷贝到<font color=\"red\">HEAD</font>标签间</font></center><form name=\"genCode\"><center><textarea cols=55 rows=16 name=\"Head\" wrap=\"Virtual\"></textarea><p><font face=\"宋体\">如下代码拷贝到<font color=\"red\">BODY </font>标签间</font><p><textarea cols=55 rows=16 name=\"Body\" wrap=\"Virtual\"></textarea><p><input type=\"Button\" value=\"Close \" onClick=\"window.close();\"></center></form><br>");Emulate.document.write('<br><hr width=610 noshade></body></html>');
Emulate.document.genCode.Head.value=HeadCode;Emulate.document.genCode.Body.value=BodyCode;Emulate.document.close();}else
alert("You haven't made anything yet");
}
//End Hide-->
</script><title>New Page 1</title></head><body><table width=610 cellpadding=0 cellspacing=0 border=0><tr><td align=center><form name=mouseOverForm><table cellspacing=0 cellpadding=0 border=1 width=580><tr><td bgcolor=royalblue><font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>Images</b></font></td><td bgcolor=#ffcf1f rowspan=6></td><td rowspan=6 valign=top><table cellspacing=0 cellpadding=0 border=0><tr><td bgcolor=royalblue><font face="verdana, arial, helvetica" color=#ffffff size=-1><b>MouseOut Image Source</b></font></td></tr><tr><td><table><tr><td><select name=Header1 onChange="headerSelect(document.mouseOverForm.Header1, document.mouseOverForm.HeadSrc1);"><option>None</option><option>file:///</option><option>http://</option></select><br><input type=Text value= name=HeadSrc1 size=8><input type=Text value= name=SrcBox1 size=22 onBlur=CheckAndChange(1);><input type=Button value="Hard Drive" name=SrcBox1but onClick=PopDrive(1);><br><br></td></tr></table></td></tr><tr><td bgcolor=royalblue><font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>MouseOver Image Source</b></font></td></tr><tr><td><table><tr><td><select name=Header2 onChange="headerSelect(document.mouseOverForm.Header2, document.mouseOverForm.HeadSrc2);"> <option>None</option> <option>file:///</option> <option>http://</option> </select><br> <input type=Text value= name=HeadSrc2 size=8> <input type=Text value= name=SrcBox2 size=22 onBlur=CheckAndChange(2);> <input type=Button value="Hard Drive" name=SrcBox2but onClick=PopDrive(2);> <br><br> </td> </tr> </table> </td> </tr> <tr> <td bgcolor=royalblue> <font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>Control Panel</b></font> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=0 border=0> <tr> <td> <input type=Button value="Add image" name=Insert onClick=CheckAndChange(1);CheckAndChange(2);insertItem();> </td> <td> <input type=Button value="Add image below" name=InsertBelow onClick=InsertBelow();> </td> <td> </tr> <tr> <td> <input type=Button value="Update image" name=Update onClick=UpdateOption();> </td> <td> <input type=Button value="Remove image" name=Remove onClick=removeIt();> </td> </tr> <tr> <td> <input type=Button value="Clean fields" name=Clean onClick=CleanBoxes(window.document.mouseOverForm)> </td> <td> <input type=Button value="Generate Code!" name=Generate onClick=generateIt();> </td> </tr> </table> </td> </tr> </table> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <select width=240 size=6 onChange=checkAndShow() name=Images> <option>Please be patient while loading </select> </td> </tr> </table> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Create the image as a link to: </b></font><br> <input type=Text value=http:// name=URLBox size=34> </td> </tr> </table> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Target</b><font face="helvetica, arial, sans serif" size=-2><b> (for frames only)</b></font><b>:</b></font> <br> <input type=Text value= name=TargetBox size=25> </td> </tr> </table> </td> </tr> <tr> <td bgcolor=royalblue> <font face="verdana, arial, helvetica" color=#ffffff size=-1> <b>Attributes</b></font> </td> </tr> <tr> <td> <table cellspacing=0 cellpadding=5 border=0> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Width:</b></font> </td> <td> <input type=Text value= name=WidthBox size=4 onBlur=isDigit(this)> </td> <td> <font face="helvetica, arial, sans serif" size=-1><b>Name:</b></font> </td> <td> <input type=Text value= name=NameBox size=10> </td> </tr> <tr> <td> <font face="helvetica, arial, sans serif" size=-1><b>Height:</b></font> </td> <td> <input type=Text value= name=HeightBox size=4 onBlur=isDigit(this)> </td> <td> <font face="helvetica, arial, sans serif" size=-1><b>Alt:</b></font> </td> <td> <input type=Text value= name=AltBox size=10> </td> </tr> <tr> <td colspan=2 align=right> <font face="helvetica, arial, sans serif" size=-1><b>Border:</b></font> </td> <td colspan=2> <input type=Text value= name=BorderBox size=5 onBlur=isDigit(this)><p> </td> </tr> </table> </td> </tr> </table> </td> </form> </tr></table> <select> <option>None%3</body></html>
更多精彩
赞助商链接