- 爱易网页
-
ASP教程
- 动态按钮生成器(上)
日期:2011-02-10 浏览次数:20947 次
很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("数据已经更新!");
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。