欢迎光临
我们一直在努力

动态按钮生成器(上)

建站超值云服务器,限时71元/月

很cool的,大家一起来研究研究!
<html><head><meta http-equiv=content-type content="text/html; charset=gb2312"><script language="javascript">
<!–hide
//timer
speed=10;//array to make objects
imagi=new array();//numbers of link
no_of_images=0;currentimage=-1;function checkbrowser(){var bname=navigator.appname;var ver=parseint(navigator.appversion);if(bname=="netscape"&&ver>=3||bname=="microsoft internet explorer"&&ver>=4);else{alert(you need netscape navigator 3 and above or microsoft internet explorer 4 and above)
}}checkbrowser();//the image object
function imageobject(name,offsrcpro,offsrc,onsrcpro,onsrc,width,height,alt,border,url,linktarget){this.name=name;this.offsrcpro=offsrcpro;this.offsrc=offsrc;this.onsrcpro=onsrcpro;this.onsrc=onsrc;this.width=width;this.height=height;this.alt=alt;this.border=border;this.url=url;this.linktarget=linktarget;this.length=11;}function headerselect(grut,grutv){if(grut.options[0].selected){grutv.value="";}else{for(var y=0;y<grut.length;y++){if(grut.options[y].selected){grutv.value="";grutv.value+=grut.options[y].text;}}}}//function performing form validation
function checkme(me){with(me){srcbox1.focus();srcbox1.blur();srcbox2.focus();srcbox2.blur();if(urlbox.value=="http://"||urlbox.value==""){alert("连接的url没有设置");
urlbox.focus();
return false;
}if(srcbox1.value==""){alert("mouseout图片尚未设置");
srcbox1.focus();
return false;
}if(srcbox2.value==""){
alert("mouseover图片尚未设置");
srcbox2.focus();
return false;
}
if(namebox.value==""){
alert("图片尚未命名");
namebox.focus();
return false;
}
return true;}}
function checkandshow(){
with(window.document.mouseoverform.images){if(options.length!=0){for(var i=0;i<options.length;i++){if(options[i].selected){with(window.document.mouseoverform){urlbox.value=imagi[i].url;targetbox.value=imagi[i].linktarget;headsrc1.value=imagi[i].offsrcpro;headsrc2.value=imagi[i].onsrcpro;srcbox1.value=imagi[i].offsrc;srcbox2.value=imagi[i].onsrc;namebox.value=imagi[i].name;borderbox.value=imagi[i].border
altbox.value=imagi[i].alt;widthbox.value=imagi[i].width;heightbox.value=imagi[i].height;currentimage=i;if(headsrc1.value=="file:///")
header1.options[1].selected=true;else if(headsrc1.value=="http://")
header1.options[2].selected=true;else if(headsrc1.value=="")
header1.options[0].selected=true;if(headsrc2.value=="file:///")
header2.options[1].selected=true;else if(headsrc2.value=="http://")
header2.options[2].selected=true;else if(headsrc2.value=="")
header2.options[0].selected=true;}}}}
}
}function insertitem(){with(window.document.mouseoverform){if(checkme(window.document.mouseoverform)){imagi[no_of_images]=new imageobject(namebox.value,headsrc1.value,srcbox1.value,headsrc2.value,srcbox2.value,widthbox.value,heightbox.value,altbox.value,borderbox.value,urlbox.value,targetbox.value);images.length+=1;images.options[images.length-1].text=imagi[no_of_images].name;++no_of_images;cleanboxes(window.document.mouseoverform);cleanboxes(window.document.mouseoverform);}}}//clean options[0] when page loaded
function clean(){abc=document.forms[0].images;if(imagi.length==0&&abc.length!=0){for(var loop=0;loop<abc.length;loop++)
abc.options[loop]=null;}}function updateoption(){with(window.document.mouseoverform){if(currentimage!=-1){if(confirm("确信要更新这些数据?")){imagi[currentimage].url=urlbox.value;imagi[currentimage].linktarget=targetbox.value;imagi[currentimage].name=namebox.value;imagi[currentimage].offsrcpro=headsrc1.value;imagi[currentimage].onsrcpro=headsrc2.value;imagi[currentimage].offsrc=srcbox1.value;imagi[currentimage].onsrc=srcbox2.value;imagi[currentimage].width=widthbox.value;imagi[currentimage].height=heightbox.value;imagi[currentimage].alt=altbox.value;imagi[currentimage].border=borderbox.value;images.options[currentimage].text=imagi[currentimage].name;alert("数据已经更新!");cleanboxes(window.document.mouseoverform);cleanboxes(window.document.mouseoverform);}}else
alert("你尚未选择任何项目!");}}function removeit(){if(document.mouseoverform.images.selectedindex<0)
alert("你尚未选择任何项目!");with(document.mouseoverform.images){for(var t=0;t<length;t++){if(options[t].selected){if(confirm("确信移去图片?")){for(var z=t;z<length-1;z++){imagi[z].url=imagi[z+1].url;imagi[z].linktarget=imagi[z+1].linktarget;imagi[z].offsrcpro=imagi[z+1].offsrcpro;imagi[z].onsrcpro=imagi[z+1].onsrcpro;imagi[z].offsrc=imagi[z+1].offsrc;imagi[z].onsrc=imagi[z+1].onsrc;imagi[z].name=imagi[z+1].name;imagi[z].border=imagi[z+1].border;imagi[z].alt=imagi[z+1].alt;imagi[z].height=imagi[z+1].height;imagi[z].width=imagi[z+1].width;}
imagi.length-=1;–no_of_images;options[t]=null;cleanboxes(window.document.mouseoverform);}}}}}
function debug(){var no=prompt("please enter the object number you want to debug","");var second_argu="imagi["+no+"]";show_props(imagi[no],second_argu);}//for debugging usage
function show_props(obj,obj_name){var result="";for(var i in obj)
result+=obj_name+"."+i+" = "+obj[i]+"\n";alert(result);}//clean the options[0] when page loaded
function clean(){abc=document.mouseoverform.images;if(imagi.length==0&&abc.length!=0){for(var loop=0;loop<abc.length;loop++)
abc.options[loop]=null;}}//clean the value in the fields
function cleanboxes(argv){var x=0;//counter
while(x!=argv.length-1){
if(argv.elements[x].type=="text"){argv.elements[x].value="";}x++;argv.urlbox.value="http://";argv.header1.options[0].selected=true;argv.header2.options[0].selected=true;argv.headsrc1.focus();argv.headsrc1.blur();argv.headsrc1.value="";argv.headsrc2.focus();argv.headsrc2.blur();argv.headsrc2.value="";
argv.srcbox1.focus();argv.srcbox1.blur();argv.srcbox1.value="";argv.srcbox2.focus();argv.srcbox2.blur();argv.srcbox2.value="";
argv.urlbox.focus();}}closedd=true;function popdrive(no){if(closedd){box=no;first=<html><body bgcolor="white" text="#000000" link="#000099" vlink="#663366" alink="#ff0000" onunload="window.opener.closedd=true;" ><center><br><form><input type="file" name="drive"><br><br><input type="button" value="ok" name="ok" onclick="window.opener.make(document.forms[0], + box + ); + window.opener.checkandchange( + box + ); + "><input type="button" name="cancel" value="cancel" onclick="window.close();window.opener.closedd=true;"></form></center><blockquote><font face="宋体" size=2>通过"浏览"按钮从硬盘上选择图片文件,然后按"ok"继续。</font></blockquote></body></html>;pop=window.open("","drivewin","width=350,height=200,resizable=yes");pop.document.open();pop.document.write(first);closedd=false;}else
pop.focus();}function make(na,no){na.drive.focus();na.drive.blur();if(na.drive.value==""){
alert("文件尚未选择!");pop.focus();}else{if(no==1){document.mouseoverform.srcbox1.value=na.drive.value;
document.mouseoverform.header1.options[1].selected=true;document.mouseoverform.headsrc1.value="file:///";}else if(no==2){document.mouseoverform.srcbox2.value=na.drive.value;
document.mouseoverform.header1.options[1].selected=true;document.mouseoverform.headsrc2.value="file:///";}pop.close();window.closedd=true;}}//check the image source,then change the protocol if needed
function checkandchange(no){if(no==1){srcbox=document.mouseoverform.srcbox1;selection=document.mouseoverform.header1;protocolbox=document.mouseoverform.headsrc1;}else if(no==2){srcbox=document.mouseoverform.srcbox2;selection=document.mouseoverform.header2;protocolbox=document.mouseoverform.headsrc2;}var c=srcbox.value.indexof("http://");var d=srcbox.value.indexof("file:///");if(c>=0){selection.options[2].selected=true;protocolbox.value="http://";stringo2=srcbox.value.substring(c+7);srcbox.value=stringo2;}else if(d>=0){selection.options[1].selected=true;protocolbox.value="file:///";stringo3=srcbox.value.substring(d+8);srcbox.value=stringo3;}var find2=srcbox.value.indexof("/")
if(srcbox.value.indexof(":\\")>0||srcbox.value.indexof("|/")>0){selection.options[1].selected=true;protocolbox.value="file:///";var cr=srcbox.value.indexof(":\\");if(cr>=0){srcbox.value=stringinsert(srcbox.value,"|",cr);for(var countit=cr;countit<srcbox.value.length;countit++){var athere=srcbox.value.charat(countit);if(athere=="\\")
srcbox.value=stringinsert(srcbox.value,"/",countit);
}}}else if((srcbox.value.indexof(".com")>0)||(srcbox.value.indexof(".edu")>0)||(srcbox.value.indexof(".org")>0)||(srcbox.value.indexof(".net")>0)||(srcbox.value.indexof(".gov")>0)||(srcbox.value.indexof(".mil")>0)||(srcbox.value.indexof(".arpa")>0)||(srcbox.value.indexof(".int")>0)){selection.options[2].selected=true;protocolbox.value="http://";}else if(find2>0){var yes=0;var c=0;var stringoo2=srcbox.value.substring(0,find2);for(var a=0;a<3;a++){
var b=stringoo2.indexof(".",c);if(b>0){c=b+1;
yes++;}}if(yes==3){
selection.options[2].selected=true;protocolbox.value="http://";}}
else{selection.options[0].selected=true;protocolbox.value="";}if(srcbox.value!=""){var stringo=srcbox.value.touppercase();if(stringo.indexof(".gif")<0&&stringo.indexof(".jpg")<0&&stringo.indexof(".jpeg")<0&&stringo.indexof(".png")<0){alert("看样子没有设置正确的图片文件:)");srcbox.focus();}}}function stringinsert(initial,replace,position){start=parseint(position);end=start+replace.length;newval=initial.substring(0,start)+replace+initial.substring(end,initial.length);return newval;}function isdigit(form){for(var x=0;x<form.value.length;x++){var y=form.value.charat(x);var g=parseint(y);if(g>=0&&g<=9);else{alert("非法的参数!");form.focus();return false;}}return true;}function insertbelow()
{with(window.document.mouseoverform)
{if(images.selectedindex!=-1)
{for(var g=0;g<imagi.length-1;g++)
{if(images.options[g].selected)
{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++;

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 动态按钮生成器(上)
分享到: 更多 (0)

相关推荐

  • 暂无文章