博文
动态改变表格的宽度和起点位置(2007-09-12 11:01:00)
摘要:有时候需要动态改变表格的宽度和起点位置,可以用javascript来实现,代码如下,也可以用此方法更改表格的其他属性<script language="javascript" type="text/javascript"><!-- function onInformation(){ theNum=parseInt(document.getElementById("layer1").width); theNum+=parseInt(document.form1.aaa.value); document.getElementById("layer1").setAttribute("width",theNum); document.getElementById("layer1").style.left=parseInt(document.getElementById("layer1").style.left.replace("px",""))+100; }--></script><div id="la"> <table width="100" height="300" id="layer1" style="LEFT: 200px; TOP:60px;POSITION: absolute;"> <form name="form1" method="post"> <tr height="20"> ......
网页颜色对话框的使用(2007-09-06 15:25:00)
摘要:index.asp页面的内容<script language='JavaScript'>function SelectColor(sEL,form){ var dEL = document.all(sEL); var url = 'selcolor.asp?color='+encodeURIComponent(sEL); var arr = showModalDialog(url,window,'dialogWidth:280px;dialogHeight:250px;help:no;scroll:no;status:no'); if (arr) { form.value=arr; //sEL.style.backgroundColor=arr; }}</script><form name="form1" method="post" action=""> <input name='FontColor' type='text' value='' size='10' maxlength='10'><a href="#" onclick="SelectColor(this,FontColor)">选择颜色</a></form>selcolor.asp页面内容<HTML><HEAD><META content="text/html; charset=gb2312" http-equiv="Content-Type">
<STYLE type=text/css>TD {FONT-SIZE: 10.8pt}BODY {FONT-SIZE: 10.8pt}BUTTON {WIDTH: 5em}</STYLE>
<SCRIPT language=JavaScrip......
在IE和FF中表格某一行隐藏的代码(2007-08-31 14:42:00)
摘要:今天在做表格隐藏的时候,使用以下代码:<table width=300 border=1><tr><td align=right width="30%"> </td><td><input type="radio" name="f" onclick="qw(1)">打开 <input type="radio" name="f" onclick="qw(0)" checked>隐藏</td></tr><tr id="bcde" style="display:none"> <td align="right">显示</td> <td>显示</td></tr>
</table><script language="javascript">function qw(id){ if (id==1) { document.getElementById("bcde").style.display="block"; } else { document.getElementById("bcde").style.display="none"; } }</script>出现的问题是:IE中浏览的效果正常,是我想要的,但是,拿到FF中,效果就不是我想要的。在此感谢网友sion,他告诉我:firefox里tr的display应该是table-row,然后给出了代码:<table width=300 border=1> <tbody><tr><td align=right width="20%"> </td><td><input type="radio" name="f" onclick="qw(1)">打开 <input type="radio......
asp随机获取数据库中的记录代码(2007-08-30 12:29:00)
摘要:利用asp随机获取数据库中的记录且不出现重复的记录<!--#include file="adoconn.asp"--><%'-------------------------检索数据-----------------------strSQL = "SELECT * FROM [table]" 'Sql语句,检索数据库'Set objRS = Server.CreateObject("ADODB.Recordset") '创建记录集rs.Open strSQL,conn,1,1 '执行检索Count=rs.RecordCount '得到记录总数Item=2 '显示记录数'-------------------------检索数据-----------------------
'-------------------------------------------------------------------------------redim a(Item, 3),t(Count)'定义2数组,数组a用来储存记录,数组t用来删选记录
'-----------------------------------......
html页面传值问题(2007-08-21 07:46:00)
摘要:有时候在浏览网页的时候会发现:有的网站用html来传值,根据传值的不同显示不同的内容。其代码 <script language="JavaScript" type="text/javascript"> <!-- str=location.href; //获取本页url地址 arr=str.split("?"); str1 = arr[1]; arr1=str1.split("="); alert(arr1[0]); alert(arr1[1]); //得到这两个值后,要显示的内容可能通过ajax或iframe来获取了 //--> </script>......
生成静态页面方法二(2007-08-17 15:11:00)
摘要:原理:用asp获取动态页面的html代码后,再将这些html代码写成html代码。<%Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")path=server.mappath("index.html")If Myfileobject.fileexists(path) Then '如果存在此文件,删除之 MyfileObject.deletefile pathEnd IfSet MyTextFile=MyFileObject.CreateTextFile(path)strurl="http://www.sina.com.cn/" '这里可以换成其他动态页面的地址。strTmp = GetHTTPPage(trim(strurl))
MyTextFile.WriteLine(strTmp)
MytextFile.Closeresponse.write "完成任务"%>
<%Function getHTTPPage(url) On Error Resume Next dim http set http=Server.createobject("Microsoft.XMLHTTP") Http.open "GET",url,false Http.send() if Http.readystate<>4 then exit function end if getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312") set http=nothing If Err.number<>0 then Response.Write "<p align='center'><font color='red'><b>服务器获取文件内容出错</b></font></p>" Err.Clear End If End Fu......
ASP备份和恢复MSSQL数据库的操作方法(2007-08-16 08:48:00)
摘要:利用asp实现对mssql数据库的备份和恢复。1、备份 <% SQL="backup database 数据库名 to disk='"&Server.MapPath("backup")&"\"&"backuptext.dat"&"'" set cnn=Server.createobject("adodb.connection") cnn.open "driver={SQL Server};Server=服务器名;uid=sa;pwd=" cnn.execute SQL on error resume next if err<>0 then response.write "错误:"&err.Descripting else response.write "数据备份成功!" end if %> 2、恢复 <% SQL="Restore database 数据库名 from disk='"&Server.MapPath("backup")&"\"&"backuptext.dat"&"'" set cnn=Server.createobject("adodb.connection") cnn.open "driver={SQL Server};Server=服务器名;uid=sa;pwd=" cnn.execute SQL on error resume next if err<>0 then response.write "错误:"&err.Descripting else response.write "数据恢复成功!" end if %>......
动态改变div的z-index属性(2007-08-13 13:07:00)
摘要:<script language="javascript"> var MAX_INDEX=4; function change(ddd) { if(ddd.style.zIndex<= MAX_INDEX) { ddd.style.zIndex = MAX_INDEX+1; MAX_INDEX++; } } </script> <div id="layer1" onclick="javascript:change(this);" style="position:absolute;margin-left:100;margin-top:50px;margin-=100;width=100;height=100;background-color:#ff0000;z-index:1"></div> <div id="layer2" onclick="javascript:change(this);" style="position:absolute;margin-left:120;margin-top:60px;margin-=120;width=100;height=100;background-color:#00ff00;z-index:2"></div> <div id="layer3" onclick="javascript:change(this);"  ......
asp天气预报采集代码(2007-08-07 13:49:00)
摘要:<%'此程序用来获取北京的天气预报,可以将北京换成你想要的地点。strurl="http://weather.tq121.com.cn/mapanel/index1.php?city=北京"s1="<table width=""166"" height=""15"" border=""0"" cellpadding=""0"" cellspacing=""0"">"s2="<table width=""169"" height=""37"" border=""0"" cellpadding=""0"" cellspacing=""5"">" Dim j1,l,b(3) strTmp = GetHTTPPage(strurl) wstr=strCut(strTmp, s1,s2,2) ' wstr=Replace(s1&wstr,"<br>","|") wstr=Replace(wstr,"</table>","</table>|") wstr=RemoveHTML(wstr) wstr=Replace(wstr,Chr(10),"") wstr=Replace(wstr,Chr(32),"") wstr=Replace(wstr," ","") str=Split(wstr,"|") For i=0 To 3 response.write str(i)&"<br>" nextresponse.End%><%Function regExReplace(sSource,patrn, replStr) Dim regEx, str1 str1 = sSource Set regEx = New RegExp regEx.Pattern = patrn regEx.IgnoreCase = True regEx.Global = True regExReplace = regEx.Replace(str1, r......
利用fso显示某一文件夹中的所有内容(2007-08-01 09:41:00)
摘要:利用fso显示某一文件夹中的所有内容<%'创建一个FileSystemObject对象的事例Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")path=server.mappath("./folder") '当前目录下folder文件夹目录'创建一个Folder对象Set MyFolder=MyFileObject.GetFolder(path)For Each thing in MyFolder.SubFolders '获取子文件夹 response.write "<p>目录:"&thing' MyFileObject.DeleteFolder thing 删除文件夹,注意使用next '循环显示其中文件For Each thing in MyFolder.FilesResponse.Write("<p>文件:"&thing) '输出文件路径'MyFileObject.DeleteFile thing '删除这些文件,此删除不可以恢复,需要小心使用Next%>......
