针对有网友说看不见文章内容, 现提示如下: 点击每一个标题行任一地方都会展开和隐藏此文章内容(不要点击标题). 目前展开隐藏功能只支持IE浏览器,虽然可以改成支持FF浏览器,不过现在一直没时间去弄,等有时间再修改了。 |
blog名称:乱闪Blog 日志总数:267 评论数量:1618 留言数量:-26 访问次数:2675126 建立时间:2005年1月1日 |
|

| |
网页制作必備之初級代碼 
|
1.获得系统时间:<%=now()%>2.取得来访用的IP:<%=request.servervariables("remote_host")%>3.获得系统,浏览器版本:<script>window.document.write("版本:"+navigator.appName+navigator.appVersion+" browser.")</script>4.去除IE混动条:<body scroll="no"> <body style="overflow-y:hidden">5.进入网站,跳出广告:<script language="javascript"><!-- <!-- 注意更改文件所在路径-->window.open(''http://www.******.com','''',''height=200,width=300,top=0,left=30'');// --></script>6.随机数:<%randomize%><%=(int(rnd()*n)+1)%>N为可改变数7.向上混动代码:<marquee direction="up" scrolldelay="200" style="font-size: 9pt; color: #FF0000; line-height: 150%; font-style:italic; font-weight:bold" scrollamount="2" width="206" height="207" bgcolor="#FFFF00">hhhhhhhhhhhhhhhhhhh</marquee>8.自动关闭网页:<script LANGUAGE="javascript"><!--setTimeout(''window.close();'', 10000); //60秒后关闭// --></script><p align="center">本页10秒后自动关闭,请注意刷新页面</p>9.随机背景音乐:<%randomize%><bgsound src="mids/<%=(int(rnd()*60)+1)%>.mid" loop="-1"> 可以修改数字,限制调用个数,我这里是60个.10.自动刷新本页面:<script> <!-- var limit="0:10" if (document.images){ var parselimit=limit.split(":") parselimit=parselimit[0]*60+parselimit[1]*1 } function beginrefresh(){ if (!document.images) return if (parselimit==1) window.location.reload() else{ parselimit-=1 curmin=Math.floor(parselimit/60) cursec=parselimit%60 if (curmin!=0) curtime=curmin+"分"+cursec+"秒后重刷本页!" else curtime=cursec+"秒后重刷本页!" window.status=curtime setTimeout("beginrefresh()",1000) } } window.onload=beginrefresh file://--> </script>11.ACCESS数据库连接:<%option explicitdim startime,endtime,conn,connstr,dbstartime=timer()'更改数据库名字db="data/dvBBS5.mdb"Set conn = Server.CreateObject("ADODB.Connection")connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)'如果你的服务器采用较老版本Access驱动,请用下面连接方法'connstr="driver={Microsoft Access Driver (*.mdb)};dbq=" & Server.MapPath(db)conn.Open connstrfunction CloseDatabaseConn.closeSet conn = NothingEnd function%>12.SQL数据库连接:<%option explicitdim startime,endtime,conn,connstr,dbstartime=timer()connstr="driver={SQL Server};server=HUDENQ-N11T33NB;uid=sa;pwd=xsfeihu;database=dvbbs" Set conn = Server.CreateObject("ADODB.Connection")conn.Open connstrfunction CloseDatabaseConn.closeSet conn = NothingEnd function%>13.用键盘打开网页代码:<script language="javascript">function ctlent(eventobject){if((event.ctrlKey && window.event.keyCode==13)||(event.altKey && window.event.keyCode==83)){window.open('网址','','')}}</script> 这里是Ctrl+Enter和Alt+S的代码 自己查下键盘的ASCII码再换就行14.让层不被控件复盖代码:<div z-Index:2><object ***></object></div> # 前面 <div z-Index:1><object ***></object></div> # 后面 <div id="Layer2" style="position:absolute; top:40;width:400px; height:95px;z-index:2"><table height=100% width=100% bgcolor="#ff0000"><tr><td height=100% width=100%></td></tr></table><iframe width=0 height=0></iframe></div><div id="Layer1" style="position:absolute; top:50;width:200px; height:115px;z-index:1"><iframe height=100% width=100%></iframe></div>15.FLASH广告代码:<object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="468" height="60"><param name=movie value="images/yj16d.swf"><param name=quality value=high><embed src="images/dvbanner.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash";;;; type="application/x-shockwave-flash" width="468" height="60"></embed></object>16.VBS弹出窗口小代码:<script language=vbscript>msgbox"你还没有注册或登陆论坛","0","精品论坛"location.href = "login.asp"</script>16.使用FSO修改文件特定内容的函数function FSOchange(filename,Target,String)Dim objFSO,objCountFile,FiletempDataSet objFSO = Server.CreateObject("scripting.FileSystemObject")Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)FiletempData = objCountFile.ReadAllobjCountFile.CloseFiletempData=Replace(FiletempData,Target,String)Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)objCountFile.Write FiletempData objCountFile.CloseSet objCountFile=NothingSet objFSO = NothingEnd function17.使用FSO读取文件内容的函数function FSOFileRead(filename)Dim objFSO,objCountFile,FiletempDataSet objFSO = Server.CreateObject("scripting.FileSystemObject")Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)FSOFileRead = objCountFile.ReadAllobjCountFile.CloseSet objCountFile=NothingSet objFSO = NothingEnd function18.使用FSO读取文件某一行的函数function FSOlinedit(filename,lineNum)if linenum < 1 then exit functiondim fso,f,temparray,tempcntset fso = server.CreateObject("scripting.filesystemobject")if not fso.fileExists(server.mappath(filename)) then exit functionset f = fso.opentextfile(server.mappath(filename),1)if not f.AtEndofStream thentempcnt = f.readallf.closeset f = nothingtemparray = split(tempcnt,chr(13)&chr(10))if lineNum>ubound(temparray)+1 thenexit functionelseFSOlinedit = temparray(lineNum-1)end ifend ifend function19.使用FSO写文件某一行的函数function FSOlinewrite(filename,lineNum,Linecontent)if linenum < 1 then exit functiondim fso,f,temparray,tempCntset fso = server.CreateObject("scripting.filesystemobject")if not fso.fileExists(server.mappath(filename)) then exit functionset f = fso.opentextfile(server.mappath(filename),1)if not f.AtEndofStream thentempcnt = f.readallf.closetemparray = split(tempcnt,chr(13)&chr(10))if lineNum>ubound(temparray)+1 thenexit functionelsetemparray(lineNum-1) = lineContentend iftempcnt = join(temparray,chr(13)&chr(10))set f = fso.createtextfile(server.mappath(filename),true)f.write tempcntend iff.closeset f = nothingend function20.使用FSO添加文件新行的函数function FSOappline(filename,Linecontent)dim fso,fset fso = server.CreateObject("scripting.filesystemobject")if not fso.fileExists(server.mappath(filename)) then exit functionset f = fso.opentextfile(server.mappath(filename),8,1)f.write chr(13)&chr(10)&Linecontentf.closeset f = nothingend function21.读文件最后一行的函数function FSOlastline(filename)dim fso,f,temparray,tempcntset fso = server.CreateObject("scripting.filesystemobject")if not fso.fileExists(server.mappath(filename)) then exit functionset f = fso.opentextfile(server.mappath(filename),1)if not f.AtEndofStream thentempcnt = f.readallf.closeset f = nothingtemparray = split(tempcnt,chr(13)&chr(10))FSOlastline = temparray(ubound(temparray))end ifend function利用FSO取得BMP,JPG,PNG,GIF文件信息(大小,宽、高等)<%'::: BMP, GIF, JPG and PNG ::: '::: This function gets a specified number of bytes from any :::'::: file, starting at the offset (base 1) :::'::: :::'::: Passed: :::'::: flnm => Filespec of file to read :::'::: offset => Offset at which to start reading :::'::: bytes => How many bytes to read :::'::: :::':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::function GetBytes(flnm, offset, bytes)Dim objFSODim objFTempDim objTextStreamDim lngSizeon error resume nextSet objFSO = CreateObject("scripting.FileSystemObject") ' First, we get the filesizeSet objFTemp = objFSO.GetFile(flnm)lngSize = objFTemp.Sizeset objFTemp = nothingfsoForReading = 1Set objTextStream = objFSO.OpenTextFile(flnm, fsoForReading)if offset > 0 thenstrBuff = objTextStream.Read(offset - 1)end ifif bytes = -1 then ' Get All!GetBytes = objTextStream.Read(lngSize) 'ReadAllelseGetBytes = objTextStream.Read(bytes)end ifobjTextStream.Closeset objTextStream = nothingset objFSO = nothingend function':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'::: :::'::: functions to convert two bytes to a numeric value (long) :::'::: (both little-endian and big-endian) :::'::: :::':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::function lngConvert(strTemp)lngConvert = clng(asc(left(strTemp, 1)) + ((asc(right(strTemp, 1)) * 256)))end functionfunction lngConvert2(strTemp)lngConvert2 = clng(asc(right(strTemp, 1)) + ((asc(left(strTemp, 1)) * 256)))end function':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'::: :::'::: This function does most of the real work. It will attempt :::'::: to read any file, regardless of the extension, and will :::'::: identify if it is a graphical image. :::'::: :::'::: Passed: :::'::: flnm => Filespec of file to read :::'::: width => width of image :::'::: height => height of image :::'::: depth => color depth (in number of colors) :::'::: strImageType=> type of image (e.g. GIF, BMP, etc.) :::'::: :::':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::function gfxSpex(flnm, width, height, depth, strImageType)dim strPNG dim strGIFdim strBMPdim strTypestrType = ""strImageType = "(unknown)"gfxSpex = FalsestrPNG = chr(137) & chr(80) & chr(78)strGIF = "GIF"strBMP = chr(66) & chr(77)strType = GetBytes(flnm, 0, 3)if strType = strGIF then ' is GIFstrImageType = "GIF"Width = lngConvert(GetBytes(flnm, 7, 2))Height = lngConvert(GetBytes(flnm, 9, 2))Depth = 2 ^ ((asc(GetBytes(flnm, 11, 1)) and 7) + 1)gfxSpex = Trueelseif left(strType, 2) = strBMP then ' is BMPstrImageType = "BMP"Width = lngConvert(GetBytes(flnm, 19, 2))Height = lngConvert(GetBytes(flnm, 23, 2))Depth = 2 ^ (asc(GetBytes(flnm, 29, 1)))gfxSpex = Trueelseif strType = strPNG then ' Is PNGstrImageType = "PNG"Width = lngConvert2(GetBytes(flnm, 19, 2))Height = lngConvert2(GetBytes(flnm, 23, 2))Depth = getBytes(flnm, 25, 2)select case asc(right(Depth,1))case 0Depth = 2 ^ (asc(left(Depth, 1)))gfxSpex = Truecase 2Depth = 2 ^ (asc(left(Depth, 1)) * 3)gfxSpex = Truecase 3Depth = 2 ^ (asc(left(Depth, 1))) '8gfxSpex = Truecase 4Depth = 2 ^ (asc(left(Depth, 1)) * 2)gfxSpex = Truecase 6Depth = 2 ^ (asc(left(Depth, 1)) * 4)gfxSpex = Truecase elseDepth = -1end select elsestrBuff = GetBytes(flnm, 0, -1) ' Get all bytes from filelngSize = len(strBuff)flgFound = 0strTarget = chr(255) & chr(216) & chr(255)flgFound = instr(strBuff, strTarget)if flgFound = 0 thenexit functionend ifstrImageType = "JPG"lngPos = flgFound + 2ExitLoop = falsedo while ExitLoop = False and lngPos < lngSize do while asc(mid(strBuff, lngPos, 1)) = 255 and lngPos < lngSizelngPos = lngPos + 1loopif asc(mid(strBuff, lngPos, 1)) < 192 or asc(mid(strBuff, lngPos, 1)) > 195 thenlngMarkerSize = lngConvert2(mid(strBuff, lngPos + 1, 2))lngPos = lngPos + lngMarkerSize + 1elseExitLoop = Trueend ifloop'if ExitLoop = False thenWidth = -1Height = -1Depth = -1elseHeight = lngConvert2(mid(strBuff, lngPos + 4, 2))Width = lngConvert2(mid(strBuff, lngPos + 6, 2))Depth = 2 ^ (asc(mid(strBuff, lngPos + 8, 1)) * 8)gfxSpex = Trueend if end ifend function':::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::'::: Test Harness :::'::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ' To test, we'll just try to show all files with a .GIF extension in the root of C:Set objFSO = CreateObject("scripting.FileSystemObject")Set objF = objFSO.GetFolder("c:\")Set objFC = objF.Filesresponse.write "<table border=""0"" cellpadding=""5"">"For Each f1 in objFCif instr(ucase(f1.Name), ".GIF") thenresponse.write "<tr><td>" & f1.name & "</td><td>" & f1.DateCreated & "</td><td>" & f1.Size & "</td><td>"if gfxSpex(f1.Path, w, h, c, strType) = true thenresponse.write w & " x " & h & " " & c & " colors"elseresponse.write " "end ifresponse.write "</td></tr>"end ifNextresponse.write "</table>"set objFC = nothingset objF = nothingset objFSO = nothing %>
22.点击返回上页代码:<form><p><input TYPE="button" value="返回上一步" onCLICK="history.back(-1)"></p></form>23.点击刷新代码:<form><p><input TYPE="button" value="刷新按钮一"onCLICK="ReloadButton()"></p></form><script language="javascript"><!--function ReloadButton(){location.href="allbutton.htm";}// --></script> 24.点击刷新代码2:<form><p><input TYPE="button" value="刷新按钮二" onClic="history.go(0)"> </p></form> <form><p><input TYPE="button" value="打开一个网站" onCLICK="HomeButton()"></p></form><script language="javascript"><!--function HomeButton(){location.href="http://nettrain.126.com";;;;}// --></script> 25.弹出警告框代码:<form><p><input TYPE="button" value="弹出警告框" onCLICK="AlertButton()"></p></form><script language="javascript"><!--function AlertButton(){window.alert("要多多光临呀!");}// --></script> 26.状态栏信息<form><p><input TYPE="button" value="状态栏信息" onCLICK="StatusButton()"></p></form><script language="javascript"><!--function StatusButton(){window.status="要多多光临呀!";}// --></script> 27.背景色变换<form><p><input TYPE="button" value="背景色变换" onClick="BgButton()"></p></form><script>function BgButton(){if (document.bgColor=='#00ffff'){document.bgColor='#ffffff';}else{document.bgColor='#00ffff';}}</script> 28.点击打开新窗口<form><p><input TYPE="button" value="打开新窗口" onCLICK="NewWindow()"></p></form><script language="javascript"><!--function NewWindow(){window.open("http://www.mcmx.com";;;,"","height=240,width=340,status=no,location=no,toolbar=no,directories=no,menubar=no");}// --></script></body>29.分页代码:<%''本程序文件名为:Pages.asp%><%''包含ADO常量表文件adovbs.inc,可从"\Program Files\Common Files\System\ADO"目录下拷贝%><!--#Include File="adovbs.inc"--><%''*建立数据库连接,这里是Oracle8.05数据库Set conn=Server.CreateObject("ADODB.Connection") conn.Open "Provider=msdaora.1;Data Source=YourSrcName;User ID=YourUserID;Password=YourPassword;" Set rs=Server.CreateObject("ADODB.Recordset") ''创建Recordset对象rs.CursorLocation=adUseClient ''设定记录集指针属性''*设定一页内的记录总数,可根据需要进行调整 rs.PageSize=10 ''*设置查询语句 StrSQL="Select ID,姓名,住址,电话 from 通讯录 Order By ID" rs.Open StrSQL,conn,adOpenStatic,adLockReadOnly,adCmdText%><HTML><HEAD><title>分页示例</title><script language=javascript>//点击"[第一页]"时响应:function PageFirst(){ document.MyForm.CurrentPage.selectedIndex=0;document.MyForm.CurrentPage.onchange();}//点击"[上一页]"时响应:function PagePrior(){ document.MyForm.CurrentPage.selectedIndex--;document.MyForm.CurrentPage.onchange();}//点击"[下一页]"时响应:function PageNext(){ document.MyForm.CurrentPage.selectedIndex++;document.MyForm.CurrentPage.onchange(); }//点击"[最后一页]"时响应:function PageLast(){ document.MyForm.CurrentPage.selectedIndex=document.MyForm.CurrentPage.length-1;document.MyForm.CurrentPage.onchange();}//选择"第?页"时响应:function PageCurrent(){ //Pages.asp是本程序的文件名document.MyForm.action='Pages.asp?Page='+(document.MyForm.CurrentPage.selectedIndex+1)document.MyForm.submit();} </script></HEAD><BODY bgcolor="#ffffcc" link="#008000" vlink="#008000" alink="#FF0000""> <%IF rs.Eof THENResponse.Write("<font size=2 color=#000080>[数据库中没有记录!]</font>")ELSE ''指定当前页码If Request("CurrentPage")="" Thenrs.AbsolutePage=1Elsers.AbsolutePage=CLng(Request("CurrentPage"))End If ''创建表单MyForm,方法为GetResponse.Write("<form method=Get name=MyForm>") Response.Write("<p align=center><font size=2 color=#008000>")''设置翻页超链接if rs.PageCount=1 then Response.Write("[第一页] [上一页] [下一页] [最后一页] ")else if rs.AbsolutePage=1 thenResponse.Write("[第一页] [上一页] ")Response.Write("[<a href=java script:PageNext()>下一页</a>] ") Response.Write("[<a href=java script:PageLast()>最后一页</a>] ") else if rs.AbsolutePage=rs.PageCount thenResponse.Write("[<a href=java script:PageFirst()>第一页</a>] ") Response.Write("[<a href=java script:PagePrior()>上一页</a>] ") Response.Write("[下一页] [最后一页] ")elseResponse.Write("[<a href=java script:PageFirst()>第一页</a>] ") Response.Write("[<a href=java script:PagePrior()>上一页</a>] ") Response.Write("[<a href=java script:PageNext()>下一页</a>] ") Response.Write("[<a href=java script:PageLast()>最后一页</a>] ") end ifend ifend if ''创建下拉列表框,用于选择浏览页码Response.Write("第<select size=1 name=CurrentPage onchange=PageCurrent()>") For i=1 to rs.PageCount if rs.AbsolutePage=i thenResponse.Write("<option selected>"&i&"</option>") ''当前页码elseResponse.Write("<option>"&i&"</option>")end if Next Response.Write("</select>页/共"&rs.PageCount&"页 共"&rs.RecordCount&"条记录</font><p>") Response.Write("</form>") ''创建表格,用于显示Response.Write("<table align=center cellspacing=1 cellpadding=1 border=1") Response.Write(" bordercolor=#99CCFF bordercolordark=#b0e0e6 bordercolorlight=#000066>") Response.Write("<tr bgcolor=#ccccff bordercolor=#000066>") Set Columns=rs.Fields ''显示表头For i=0 to Columns.Count-1Response.Write("<td align=center width=200 height=13>")Response.Write("<font size=2><b>"&Columns(i).name&"</b></font></td>") NextResponse.Write("</tr>")''显示内容For i=1 to rs.PageSize Response.Write("<tr bgcolor=#99ccff bordercolor=#000066>") For j=0 to Columns.Count-1 Response.Write("<td><font size=2>"&Columns(j)&"</font></td>") NextResponse.Write("</tr>") rs.movenext if rs.EOF then exit for Next Response.Write("</table>") END IF%></BODY></HTML>
40种网页常用小技巧(JavaScript) 1. oncontextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键<table border oncontextmenu=return(false)><td>no</table> 可用于Table2. <body onselectstart="return false"> 取消选取、防止复制3. onpaste="return false" 不准粘贴4. oncopy="return false;" oncut="return false;" 防止复制5. <link rel="Shortcut Icon" href="favicon.ico"> IE地址栏前换成自己的图标6. <link rel="Bookmark" href="favicon.ico"> 可以在收藏夹中显示出你的图标7. <input style="ime-mode:disabled"> 关闭输入法8. 永远都会带着框架<script language="JavaScript"><!--if (window == top)top.location.href = "frames.htm"; //frames.htm为框架网页// --></script>9. 防止被人frame<SCRIPT LANGUAGE=JAVASCRIPT><!-- if (top.location != self.location)top.location=self.location;// --></SCRIPT>10. 网页将不能被另存为<noscript><iframe src=*.html></iframe></noscript> 11. <input type=button value=查看网页源代码 onclick="window.location = "view-source:"+ "http://www.pconline.com.cn"">12.删除时确认<a href="javascript :if(confirm("确实要删除吗?"))location="boos.asp?&areyou=删除&page=1"">删除</a> 13. 取得控件的绝对位置//Javascript<script language="Javascript">function getIE(e){var t=e.offsetTop;var l=e.offsetLeft;while(e=e.offsetParent){t+=e.offsetTop;l+=e.offsetLeft;}alert("top="+t+"/nleft="+l);}</script>//VBScript<script language="VBScript"><!--function getIE()dim t,l,a,bset a=document.all.img1t=document.all.img1.offsetTopl=document.all.img1.offsetLeftwhile a.tagName<>"BODY"set a = a.offsetParentt=t+a.offsetTopl=l+a.offsetLeftwendmsgbox "top="&t&chr(13)&"left="&l,64,"得到控件的位置"end function--></script>14. 光标是停在文本框文字的最后<script language="javascript">function cc(){var e = event.srcElement;var r =e.createTextRange();r.moveStart("character",e.value.length);r.collapse(true);r.select();}</script><input type=text name=text1 value="123" onfocus="cc()">15. 判断上一页的来源javascript :document.referrer16. 最小化、最大化、关闭窗口<object id=hh1 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Minimize"></object><object id=hh2 classid="clsid:ADB880A6-D8FF-11CF-9377-00AA003B7A11"> <param name="Command" value="Maximize"></object><OBJECT id=hh3 classid="clsid:adb880a6-d8ff-11cf-9377-00aa003b7a11"><PARAM NAME="Command" VALUE="Close"></OBJECT><input type=button value=最小化 onclick=hh1.Click()><input type=button value=最大化 onclick=hh2.Click()><input type=button value=关闭 onclick=hh3.Click()>本例适用于IE17.屏蔽功能键Shift,Alt,Ctrl<script>function look(){ if(event.shiftKey) alert("禁止按Shift键!"); //可以换成ALT CTRL} document.onkeydown=look; </script>18. 网页不会被缓存<META HTTP-EQUIV="pragma" CONTENT="no-cache"><META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"><META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">或者<META HTTP-EQUIV="expires" CONTENT="0">19.怎样让表单没有凹凸感?<input type=text style="border:1 solid #000000"> 或<input type=text style="border-left:none; border-right:none; border-top:none; border-bottom: 1 solid #000000"></textarea>20.<div><span>&<layer>的区别? <div>(division)用来定义大段的页面元素,会产生转行 <span>用来定义同一行内的元素,跟<div>的唯一区别是不产生转行 <layer>是ns的标记,ie不支持,相当于<div>21.让弹出窗口总是在最上面:<body onblur="this.focus();">22.不要滚动条? 让竖条没有: <body style="overflow:scroll;overflow-y:hidden"> </body> 让横条没有: <body style="overflow:scroll;overflow-x:hidden"> </body> 两个都去掉?更简单了 <body scroll="no"> </body> 23.怎样去掉图片链接点击后,图片周围的虚线?<a href="#" onFocus="this.blur()"><img src="logo.jpg" border=0></a>24.电子邮件处理提交表单<form name="form1" method="post" action="mailto:****@***.com" enctype="text/plain"> <input type=submit></form>25.在打开的子窗口刷新父窗口的代码里如何写?window.opener.location.reload()26.如何设定打开页面的大小<body onload="top.resizeTo(300,200);">打开页面的位置<body onload="top.moveBy(300,200);">27.在页面中如何加入不是满铺的背景图片,拉动页面时背景图不动 <STYLE> body {background-image:url(logo.gif); background-repeat:no-repeat; background-position:center;background-attachment: fixed} </STYLE> 28. 检查一段字符串是否全由数字组成<script language="Javascript"><!--function checkNum(str){return str.match(//D/)==null}alert(checkNum("1232142141"))alert(checkNum("123214214a1"))// --></script>29. 获得一个窗口的大小document.body.clientWidth; document.body.clientHeight30. 怎么判断是否是字符if (/[^/x00-/xff]/g.test(s)) alert("含有汉字");else alert("全是字符");31.TEXTAREA自适应文字行数的多少<textarea rows=1 name=s1 cols=27 onpropertychange="this.style.posHeight=this.scrollHeight"></textarea>32. 日期减去天数等于第二个日期<script language=Javascript>function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() + 1) + "月" + a.getDate() + "日")}cc("12/23/2002",2)</script>33. 选择了哪一个Radio<HTML><script language="vbscript">function checkme()for each ob in radio1if ob.checked then window.alert ob.valuenextend function</script><BODY><INPUT name="radio1" type="radio" value="style" checked>Style<INPUT name="radio1" type="radio" value="barcode">Barcode<INPUT type="button" value="check" onclick="checkme()"></BODY></HTML>34.脚本永不出错<SCRIPT LANGUAGE="JavaScript"> <!-- Hide function killErrors() { return true; } window.onerror = killErrors; // --> </SCRIPT>35.ENTER键可以让光标移到下一个输入框<input onkeydown="if(event.keyCode==13)event.keyCode=9">36. 检测某个网站的链接速度:把如下代码加入<body>区域中:<script language=Javascript>tim=1setInterval("tim++",100)b=1var autourl=new Array()autourl[1]="www.njcatv.net"autourl[2]="javacool.3322.net"autourl[3]="www.sina.com.cn"autourl[4]="www.nuaa.edu.cn"autourl[5]="www.cctv.com"function butt(){document.write("<form name=autof>")for(var i=1;i<autourl.length;i++)document.write("<input type=text name=txt"+i+" size=10 value=测试中……> =》<input type=text name=url"+i+" size=40> =》<input type=button value=GO onclick=window.open(this.form.url"+i+".value)><br>")document.write("<input type=submit value=刷新></form>")}butt()function auto(url){document.forms[0]["url"+b].value=urlif(tim>200){document.forms[0]["txt"+b].value="链接超时"}else{document.forms[0]["txt"+b].value="时间"+tim/10+"秒"}b++}function run(){for(var i=1;i<autourl.length;i++)document.write("<img src=http://"+autourl+"/"+Math.random()+" width=1 height=1 onerror=auto("http://"+autourl+"")>")}run()</script>37. 各种样式的光标auto :标准光标default :标准箭头hand :手形光标wait :等待光标text :I形光标vertical-text :水平I形光标no-drop :不可拖动光标not-allowed :无效光标help :?帮助光标all-scroll :三角方向标move :移动标crosshair :十字标e-resizen-resizenw-resizew-resizes-resizese-resizesw-resize38.页面进入和退出的特效进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)"> 这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23: 0 矩形缩小 1 矩形扩大 2 圆形缩小 3 圆形扩大 4 下到上刷新 5 上到下刷新 6 左到右刷新 7 右到左刷新 8 竖百叶窗 9 横百叶窗 10 错位横百叶窗 11 错位竖百叶窗 12 点扩散 13 左右到中间刷新 14 中间到左右刷新 15 中间到上下 16 上下到中间 17 右下到左上 18 右上到左下 19 左上到右下 20 左下到右上 21 横条 22 竖条 23 以上22种随机选择一种39.在规定时间内跳转<META http-equiv=V="REFRESH" content="5;URL=http://www.51js.com"> 40.网页是否被检索<meta name="ROBOTS" content="属性值"> 其中属性值有以下一些: 属性值为"all": 文件将被检索,且页上链接可被查询; 属性值为"none": 文件不被检索,而且不查询页上的链接; 属性值为"index": 文件将被检索; 属性值为"follow": 查询页上的链接; 属性值为"noindex": 文件不检索,但可被查询链接; 属性值为"nofollow": 文件不被检索,但可查询页上的链接。转自: http://www.zhanling.com/zhanling/qiu/blogview.asp?logID=88&cateID=3 |
|
回复:网页制作必備之初級代碼
|
电脑与网络 wewe(游客)发表评论于2008/4/28 17:24:01 |
| |
回复:不要點擊標題鏈接,點空白處或點擊“展開內容”
|
|
操,页面不停的刷新,赚什么啊赚
|
电脑与网络 fuck(游客)发表评论于2005/3/1 10:21:12 |
| |
回复:网页制作必備之初級代碼
|
电脑与网络 panpan(游客)发表评论于2005/2/18 18:51:48 |
| |
» 1 »
|