ASP网页编程之静态按钮天生器(上)
ASP在国内异常流行,因为国内大多使用的是盗版的Windows和盗版的SQLServer,而ASP+COM+SQLServer实际上也是一种不错的搭配,其性能也不输于PHP+MYSQL,特别是Windows系统和SQLServer都有图形界面,比APACHE和MYSQL易于维护,因此对于不重视知识产权的国家来说也是一种不错的选择。很COOL的,人人一同来研讨研讨!<html><head><metahttp-equiv=Content-Typecontent="text/html;charset=gb2312"><scriptlanguage="javascript">
<!--Hide
//timer
speed=10;//ArraytomakeObjects
Imagi=newArray();//numbersofLink
no_of_images=0;currentImage=-1;functioncheckBrowser(){varbname=navigator.appName;varver=parseInt(navigator.appVersion);if(bname=="Netscape"&&ver>=3||bname=="MicrosoftInternetExplorer"&&ver>=4);else{alert(YouneedNetscapeNavigator3andaboveorMicrosoftInternetExplorer4andabove)
}}checkBrowser();//TheImageObject
functionImageObject(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;}functionheaderSelect(grut,grutv){if(grut.options.selected){grutv.value="";}else{for(vary=0;y<grut.length;y++){if(grut.options.selected){grutv.value="";grutv.value+=grut.options.text;}}}}//FunctionPerformingFormValidation
functioncheckMe(Me){with(Me){SrcBox1.focus();SrcBox1.blur();SrcBox2.focus();SrcBox2.blur();if(URLBox.value=="http://"||URLBox.value==""){alert("毗连的URL没有设置");
URLBox.focus();
returnfalse;
}if(SrcBox1.value==""){alert("MouseOut图片还没有设置");
SrcBox1.focus();
returnfalse;
}if(SrcBox2.value==""){
alert("MouseOver图片还没有设置");
SrcBox2.focus();
returnfalse;
}
if(NameBox.value==""){
alert("图片还没有定名");
NameBox.focus();
returnfalse;
}
returntrue;}}
functioncheckAndShow(){
with(window.document.mouseOverForm.Images){if(options.length!=0){for(vari=0;i<options.length;i++){if(options.selected){with(window.document.mouseOverForm){URLBox.value=Imagi.URL;TargetBox.value=Imagi.LinkTarget;HeadSrc1.value=Imagi.OffSrcPro;HeadSrc2.value=Imagi.OnSrcPro;SrcBox1.value=Imagi.OffSrc;SrcBox2.value=Imagi.OnSrc;NameBox.value=Imagi.Name;BorderBox.value=Imagi.Border
AltBox.value=Imagi.Alt;WidthBox.value=Imagi.Width;HeightBox.value=Imagi.Height;currentImage=i;if(HeadSrc1.value=="file:///")
Header1.options.selected=true;elseif(HeadSrc1.value=="http://")
Header1.options.selected=true;elseif(HeadSrc1.value=="")
Header1.options.selected=true;if(HeadSrc2.value=="file:///")
Header2.options.selected=true;elseif(HeadSrc2.value=="http://")
Header2.options.selected=true;elseif(HeadSrc2.value=="")
Header2.options.selected=true;}}}}
}
}functioninsertItem(){with(window.document.mouseOverForm){if(checkMe(window.document.mouseOverForm)){Imagi=newImageObject(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.text=Imagi.Name;++no_of_images;CleanBoxes(window.document.mouseOverForm);CleanBoxes(window.document.mouseOverForm);}}}//Cleanoptionswhenpageloaded
functionClean(){abc=document.forms.Images;if(Imagi.length==0&&abc.length!=0){for(varloop=0;loop<abc.length;loop++)
abc.options=null;}}functionUpdateOption(){with(window.document.mouseOverForm){if(currentImage!=-1){if(confirm("确信要更新这些数据?")){Imagi.URL=URLBox.value;Imagi.LinkTarget=TargetBox.value;Imagi.Name=NameBox.value;Imagi.OffSrcPro=HeadSrc1.value;Imagi.OnSrcPro=HeadSrc2.value;Imagi.OffSrc=SrcBox1.value;Imagi.OnSrc=SrcBox2.value;Imagi.Width=WidthBox.value;Imagi.Height=HeightBox.value;Imagi.Alt=AltBox.value;Imagi.Border=BorderBox.value;Images.options.text=Imagi.Name;alert("数据已更新!");CleanBoxes(window.document.mouseOverForm);CleanBoxes(window.document.mouseOverForm);}}else
alert("你还没有选择任何项目!");}}functionremoveIt(){if(document.mouseOverForm.Images.selectedIndex<0)
alert("你还没有选择任何项目!");with(document.mouseOverForm.Images){for(vart=0;t<length;t++){if(options.selected){if(confirm("确信移往图片?")){for(varz=t;z<length-1;z++){Imagi.URL=Imagi.URL;Imagi.LinkTarget=Imagi.LinkTarget;Imagi.OffSrcPro=Imagi.OffSrcPro;Imagi.OnSrcPro=Imagi.OnSrcPro;Imagi.OffSrc=Imagi.OffSrc;Imagi.OnSrc=Imagi.OnSrc;Imagi.Name=Imagi.Name;Imagi.Border=Imagi.Border;Imagi.Alt=Imagi.Alt;Imagi.Height=Imagi.Height;Imagi.Width=Imagi.Width;}
Imagi.length-=1;--no_of_images;options=null;CleanBoxes(window.document.mouseOverForm);}}}}}
functionDebug(){varno=prompt("PleaseentertheObjectnumberyouwanttodebug","");varsecond_argu="Imagi["+no+"]";show_props(Imagi,second_argu);}//fordebuggingusage
functionshow_props(obj,obj_name){varresult="";for(variinobj)
result+=obj_name+"."+i+"="+obj+"
";alert(result);}//Cleantheoptionswhenpageloaded
functionClean(){abc=document.mouseOverForm.Images;if(Imagi.length==0&&abc.length!=0){for(varloop=0;loop<abc.length;loop++)
abc.options=null;}}//Cleanthevalueinthefields
functionCleanBoxes(argv){varx=0;//counter
while(x!=argv.length-1){
if(argv.elements.type=="text"){argv.elements.value="";}x++;argv.URLBox.value="http://";argv.Header1.options.selected=true;argv.Header2.options.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;functionPopDrive(no){if(closedd){Box=no;First=<html><bodybgcolor="white"text="#000000"link="#000099"vlink="#663366"alink="#ff0000"onUnLoad="window.opener.closedd=true;"><center><br><form><inputtype="file"name="Drive"><br><br><inputtype="Button"value="OK"name="OK"><inputtype="Button"name="Cancel"value="Cancel"></form></center><blockquote><fontface="宋体"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();}functionMake(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.selected=true;document.mouseOverForm.HeadSrc1.value="file:///";}elseif(no==2){document.mouseOverForm.SrcBox2.value=na.Drive.value;
document.mouseOverForm.Header1.options.selected=true;document.mouseOverForm.HeadSrc2.value="file:///";}Pop.close();window.closedd=true;}}//Checktheimagesource,thenchangetheprotocolifneeded
functionCheckAndChange(no){if(no==1){SrcBox=document.mouseOverForm.SrcBox1;Selection=document.mouseOverForm.Header1;ProtocolBox=document.mouseOverForm.HeadSrc1;}elseif(no==2){SrcBox=document.mouseOverForm.SrcBox2;Selection=document.mouseOverForm.Header2;ProtocolBox=document.mouseOverForm.HeadSrc2;}varc=SrcBox.value.indexOf("http://");vard=SrcBox.value.indexOf("file:///");if(c>=0){Selection.options.selected=true;ProtocolBox.value="http://";Stringo2=SrcBox.value.substring(c+7);SrcBox.value=Stringo2;}elseif(d>=0){Selection.options.selected=true;ProtocolBox.value="file:///";Stringo3=SrcBox.value.substring(d+8);SrcBox.value=Stringo3;}varfind2=SrcBox.value.indexOf("/")
if(SrcBox.value.indexOf(":")>0||SrcBox.value.indexOf("|/")>0){Selection.options.selected=true;ProtocolBox.value="file:///";varcr=SrcBox.value.indexOf(":");if(cr>=0){SrcBox.value=stringInsert(SrcBox.value,"|",cr);for(varcountIt=cr;countIt<SrcBox.value.length;countIt++){varAthere=SrcBox.value.charAt(countIt);if(Athere=="")
SrcBox.value=stringInsert(SrcBox.value,"/",countIt);
}}}elseif((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.selected=true;ProtocolBox.value="http://";}elseif(find2>0){varyes=0;varc=0;varStringoo2=SrcBox.value.substring(0,find2);for(vara=0;a<3;a++){
varb=Stringoo2.indexOf(".",c);if(b>0){c=b+1;
yes++;}}if(yes==3){
Selection.options.selected=true;ProtocolBox.value="http://";}}
else{Selection.options.selected=true;ProtocolBox.value="";}if(SrcBox.value!=""){varStringo=SrcBox.value.toUpperCase();if(Stringo.indexOf(".GIF")<0&&Stringo.indexOf(".JPG")<0&&Stringo.indexOf(".JPEG")<0&&Stringo.indexOf(".PNG")<0){alert("看模样没有设置准确的图片文件:)");SrcBox.focus();}}}functionstringInsert(initial,replace,position){start=parseInt(position);end=start+replace.length;newVal=initial.substring(0,start)+replace+initial.substring(end,initial.length);returnnewVal;}functionisDigit(form){for(varx=0;x<form.value.length;x++){vary=form.value.charAt(x);varg=parseInt(y);if(g>=0&&g<=9);else{alert("不法的参数!");form.focus();returnfalse;}}returntrue;}functionInsertBelow()
{with(window.document.mouseOverForm)
{if(Images.selectedIndex!=-1)
{for(varg=0;g<Imagi.length-1;g++)
{if(Images.options.selected)
{varr=no_of_images;Imagi=newImageObject(Imagi.Name,Imagi.OffSrcPro,Imagi.OffSrc,Imagi.OnSrcPro,Imagi.OnSrc,Imagi.Width,Imagi.Height,Imagi.Alt,Imagi.Border,Imagi.URL,Imagi.LinkTarget);for(varp=Imagi.length-2;p>g;p--)
{Imagi.Name=Imagi.Name;Imagi.OffSrcPro=Imagi.OffSrcPro;Imagi.OffSrc=Imagi.OffSrc;Imagi.OnSrcPro=Imagi.OnSrcPro;Imagi.OnSrc=Imagi.OnSrc;Imagi.Width=Imagi.Width;Imagi.Height=Imagi.Height;Imagi.Alt=Imagi.Alt;Imagi.Border=Imagi.Border;Imagi.URL=Imagi.URL;Imagi.LinkTarget=Imagi.LinkTarget;}
Imagi.URL=URLBox.value;Imagi.LinkTarget=TargetBox.value;Imagi.Name=NameBox.value;Imagi.OffSrcPro=HeadSrc1.value;Imagi.OnSrcPro=HeadSrc2.value;Imagi.OffSrc=SrcBox1.value;Imagi.OnSrc=SrcBox2.value;Imagi.Width=WidthBox.value;Imagi.Height=HeightBox.value;Imagi.Alt=AltBox.value;Imagi.Border=BorderBox.value;no_of_images++;
优点:简单易学、开发速度快、有很多年“历史”,能找到非常多别人做好的程序来用、配合activeX功能强大,很多php做不到的asp+activeX能做到,例如银行安全控件 用户端的浏览器不需要提供任何别的支持,这样大提高了用户与服务器之间的交互的速度。 最近在学asp,不要问我为什么不直接学.net,因为公司网站是asp做的所以有这个需要,卖了本书asp入门到精通,对里面的六大内置对象老是记不住,还有很多属性和方法看的头晕。 ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。 以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。 ASP(ActiveServerPages)是Microsfot公司1996年11月推出的WEB应用程序开发技术,它既不是一种程序语言,也不是一种开发工具,而是一种技术框架,不须使用微软的产品就能编写它的代码,能产生和执行动态、交互式、高效率的站占服务器的应用程序。 它可通过内置的组件实现更强大的功能,如使用A-DO可以轻松地访问数据库。 如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:
页:
[1]