获取页面的HTML
<script>
var oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
oXmlHttp.open("GET","http://www.163.com", false);
oXmlHttp.send()
var oStream = new ActiveXObject("ADODB.Stream");
if(oStream == null)
alert("您的机器不支持ADODB.Stream.")
else
{
oStream.Type=1;
oStream.Mode=3;
oStream.Open() ;
oStream.Write(oXmlHttp.responseBody);
oStream.Position= 0;
oStream.Type= 2;
oStream.Charset="gb2312";
var result= oStream.ReadText();
oStream.Close();
oStream = null;
var aa = window.open("","")
document.write(result);
aa.document.write(result);
}
</script>
[新开一个窗口]============================================================================================================
window.open('filename','','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=400,height=570,top=200,left=300,bottom=0,right=0');
[关于JS调用]============================================================================================================
new.asp(调用文件)
<%
str = "循环取的要调用的数据"
'关键是下面这句,调用document函数打印输入str值--->
%>
document.write('<%=str%>')
OK,结束,在其他要调用的页面插入
<script language="javascript" src="new文件所在目录/news.asp></script>
[打开一个窗口,并且关闭当前窗口]============================================================================================================
<script language="JavaScript">
//-->
window.open('MenuMain.asp','','toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=,height=,top=0,left=0,bottom=0,right=0');
window.opener = "meizz"; //加了这句代码IE5.5+不会有关闭提示
window.close();
//--
</script>
[分页显示记录]============================================================================================================
一.
<%
dim MaxPerPage
dim totalPage
if not isempty(request("page")) then
currentPage=cint(request("page"))
else
currentPage=1
end if
%>
二.
<%
set rs=server.createobject("adodb.recordset")
sql="select top 20 * from person order by id desc"
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write "没有任何人才信息"
else
rs.pagesize=10
MaxPerPage=rs.pagesize
totalPage=rs.pagecount
if CurrentPage<1 then
CurrentPage=1
end if
if CurrentPage>totalPage then
CurrentPage=totalPage
end if
if CurrentPage>1 then
rs.move (CurrentPage-1)*MaxPerPage
dim bookmark
bookmark rs.bookmark
end if
i=1
do while not rs.eof and i<=10
%>
......本页显示的数据
<%
i=i+1
rs.movenext
loop
end if
rs.close
%>
三.
<a href="allrencai.asp?page=1>第一页  </a>
<a href="allrencai.asp?page=<%=CurrentPage-1%>上一页 </a>
<a href="allrencai.asp?page=<%=CurrentPage+1%>">下一页 </a>
<a href="allrencai.asp?page=<%=totalPage%>最末页</a>
按照上面的模式套进去就可以了,应该没什么问题!
[获取用户IP]============================================================================================================
request.servervariables("remote_addr")
[对象的显示与隐藏(style.display的应用)]============================================================================================================
document.name.style.display="none"; //隐藏
document.name.style.display="block"; //显示
[改变文本字体大小]============================================================================================================
<SCRIPT LANGUAGE="JavaScript">
<!--
function fontZoom(size)
{
document.getElementById("fontzoom").style.fontSize=size+"px"
}
//-->
</SCRIPT>
<TABLE>
<TR>
<TD id="fontzoom">1234fsdfsdfasd234234311dfasdfsd23</TD>
<TD><a href="javascript:fontZoom(12)">12</a></TD>
<TD><a href="javascript:fontZoom(18)">18</a></TD>
</TR>
</TABLE>
[随机抽取记录]============================================================================================================
rs.moveFirst
randomize
rs.move int(rnd*rs.recordCount)
[获取ID为R1的RADIO的值]============================================================================================================
<FORM name="form1" METHOD=POST ACTION="">
<INPUT type=radio value=l name="r1">左对齐
<INPUT type=radio value=r name="r1">右对齐
<INPUT type=radio CHECKED value=m name="r1">中间对齐
<INPUT type=radio value=s name="r1">两端对齐
<INPUT TYPE="button" name="cmd" value="getValue" onclick="getValue()">
</FORM>
<script language="javascript">
<!--
function getValue()
{
var msg="";
var i=0;
for(i=0;i<document.all.form1.r1.length;i++)
if(document.all.form1.r1[i].checked)alert(document.all.form1.r1[i].value);
}
-->
</script>
[向一个frame中载入页面]============================================================================================================
<HTML>
<HEAD>
<script language="JavaScript">
<!-- Hiding
function loadtwo(page2, page3) {
parent.fr2.location.href=page2;
parent.fr3.location.href=page3;
}
// -->
</script>
</HEAD>
<BODY>
<FORM NAME="buttons">
<INPUT TYPE="button" VALUE="同 时 载 入 两 份 文 件" onClick="loadtwo('frtest1.html',
'frtest2.html')">
</FORM>
</BODY>
</HTML>
[ASP动态输出一个图片或FLASH]============================================================================================================
<%
if rsDB("fileType")<>"SWF" then
%>
<a href="<%=rsDB("linkURL")%>" name="logoIMGLINK" target="_blank"><img src="/admin/adver/upload/<%=rsDB("id")%>.<%=rsDB("filetype")%>" width="550" height="100" name="logoIMG" border="0"></a>
<%
else
response.Write("<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"" width=""550"" height=""100""> <param name=""movie"" value=""/admin/adver/upload/"+cstr(rsDB("id"))+"."+rsDB("filetype")+"""> <param name=""quality"" value=""high""> <embed src=""/admin/adver/upload/"+cstr(rsDB("id"))+"."+rsDB("filetype")+" quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" type=""application/x-shockwave-flash"" width=""550"" height=""100""></embed></object>")
end if
%>
[连接SQL数据库]============================================================================================================
set dcnDB = server.createobject("ADODB.CONNECTION")
dcnDB.open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=帐号;pwd=密码;Initial Catalog=表名;Data Source=数据库IP(localhost本地)"
set rsDB = server.createobject("ADODB.RECORDSET")
[模糊查找(SQL数据库)]============================================================================================================
sql="SELECT * FROM [USER] WHERE User_Name like '%XXXXX%'"
[SQL数据库中时间的表示方法]============================================================================================================
sql="SELECT * FROM [USER] WHERE [date]<'2004-4-7'"
[浮动广告]============================================================================================================
第一步:把如下代码加入<head>区域中
<script language="JavaScript">
<!--//
//设置下面一些参数,小球移动速度1-50,数值大速度快;
var ballWidth = 40;
var ballHeight = 40;
var BallSpeed = 10;
var maxBallSpeed = 50;
var xMax;
var yMax;
var xPos = 0;
var yPos = 0;
var xDir = 'right'; //水平方向向右移动
var yDir = 'down'; //垂直方向向下移动
var superballRunning = true;
var tempBallSpeed;
var currentBallSrc;
var newXDir;
var newYDir;
function initializeBall() {
if (document.all) {
xMax = document.body.clientWidth
yMax = document.body.clientHeight
document.all("superball").style.visibility = "visible";
}
else if (document.layers) {
xMax = window.innerWidth;
yMax = window.innerHeight;
document.layers["superball"].visibility = "show";
}
setTimeout('moveBall()',400);
}
function moveBall() {
if (superballRunning == true) {
calculatePosition();
if (document.all) {
document.all("superball").style.left = xPos + document.body.scrollLeft;
document.all("superball").style.top = yPos + document.body.scrollTop;
}
else if (document.layers) {
document.layers["superball"].left = xPos + pageXOffset;
document.layers["superball"].top = yPos + pageYOffset;
}
setTimeout('moveBall()',30);
}
}
function calculatePosition() {
if (xDir == "right") {
if (xPos > (xMax - ballWidth - BallSpeed)) {
xDir = "left";
}
}
else if (xDir == "left") {
if (xPos < (0 + BallSpeed)) {
xDir = "right";
}
}
if (yDir == "down") {
if (yPos > (yMax - ballHeight - BallSpeed)) {
yDir = "up";
}
}
else if (yDir == "up") {
if (yPos < (0 + BallSpeed)) {
yDir = "down";
}
}
if (xDir == "right") {
xPos = xPos + BallSpeed;
}
else if (xDir == "left") {
xPos = xPos - BallSpeed;
}
else {
xPos = xPos;
}
if (yDir == "down") {
yPos = yPos + BallSpeed;
}
else if (yDir == "up") {
yPos = yPos - BallSpeed;
}
else {
yPos = yPos;
}
}
if (document.all||document.layers)
window.onload = initializeBall;
window.onresize = new Function("window.location.reload()");
// -->
</script>
<style type="text/css">
#superball {
position:absolute;
left:0;
top:0;
visibility:hide;
visibility:hidden;
width:40;
height:40;
}
</style>
第二步:把如下代码加入区域中:
16:16 2004-4-11
[判断文件是否存在]=============================================================================================
Set fs = server.CreateObject("scripting.filesystemobject")
if fs.FileExists(filename) then
fs.DeleteFile(filename)
end if
[用WebEasyMail发送邮件]==================================================================================
'以下是一段找回密码的过程!
sub Send_EM()
Dim mailsend
Dim sender
str="尊敬的"&request("PSQname")&":"
str=str&"<p>"
str=str&"<br/>"
str=str&" 您登录密码为:"&rsDB("Password")&",请务必记住此登陆码,<br/>因为您必须以此登陆码才能登陆本站。"
str=str&"<br/>"
str=str&" 如果您注册的是高级会员,请等待验证和通知。"
str=str&"<br/>"
str=str&" 希望能给您带来新的收获,顺祝收成日丰!"
str=str&"<br/>"
str=str&"<hr>"
str=str&"<br/>"
str=str&" Road Lab Xi'an China"
str=str& " E-mail:[email protected]"
Set mailsend = Server.CreateObject("easymail.MailSend")
mailsend.CreateNew "[email protected]","登录密码"
' 发信人名称
mailsend.MailName = "Road Lab Xi'an China"
mailsend.EM_To =rsDB("email")
'收件人邮件地址
mailsend.EM_Subject = "找回密码!!" '邮件主题"
mailsend.EM_HTML_Text =str
mailsend.useRichEditer = true
mailsend.send
set mailsend=nothing
end sub
[过滤html标签获得纯字符]====================================================================================
<SCRIPT LANGUAGE="vbScript">
Function RegExpTest(patrn, strng)
Dim regEx, Match, Matches '建立变量。
Set regEx = New RegExp '建立正则表达式。
regEx.Pattern = patrn'设置模式。
regEx.IgnoreCase = True '设置是否区分字符大小写。
regEx.Global = True '设置全局可用性。
Set Matches = regEx.Execute(strng)'执行搜索。
dim rtStr
rtStr=strng
For Each Match in Matches'遍历匹配集合。
rtStr=replace(rtStr,Match.value,"")
Next
RegExpTest = rtStr
End Function
Content=RegExpTest("<.*?>", Content)
</SCRIPT>
[解决XMLHTTP POST数据乱码问题]===============================================================================
function getValue()
dim xmlDom
set xmlDom=createobject("MSXML2.XMLHTTP")
xmlDom.open "POST","http://dheart.51.net/ip/index.php?ip=10.100.1.11",false
xmlDom.send
msgbox(bytes2BSTR(xmlDom.responsebody))
end function
Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
[SQL修改库结构]
strsql="ALTER TABLE product ADD orderID int NULL"
conn.execute(strsql)
[把DOC转成HTML文件]=============================================================================================
<HTML>
<HEAD>
<TITLE>WalkingPoison's Word-to-HTML sample</TITLE>
<script language=javascript>
function saveword(){
var oWordApp=new ActiveXObject("Word.Application");
var oDocument=oWordApp.Documents.Open("C:\\temp.doc");
oDocument.SaveAs("C:\\test.htm",8)
oWordApp.Quit();
getDOC.innerHTML=""
}
function getIframeDoc(){
alert(iframeDOC.value);
}
</script>
</HEAD>
<BODY>
Click the "save" button to save the file "C:\test.doc" to "C:\test.htm":
<input type=button onclick="saveword()" value=save>
<button onclick="getIframeDoc()">GetDoc.HTML</button>
<P> </P> <iframe src='c:\test.htm' id='iframeDOC'></iframe>
<div id="getDOC"></div>
</BODY>
</HTML>
本文地址:http://com.8s8s.com/it/it8068.htm