ASP 一些常用方法 思路 方法小汇总

来源:互联网 发布:网络大电影导演招聘 编辑:程序博客网 时间:2024/06/07 18:46

 ##########################常用汇总#######################################
1 过滤::
 mString = replace(mString, ">", ">")
    mString = replace(mString, "<", "&lt;")
    mString = Replace(mString, CHR(32), "&nbsp;")
    mString = Replace(mString, CHR(9), "&nbsp;")
    mString = Replace(mString, CHR(34), "&quot;")
    mString = Replace(mString, CHR(39), "&#39;")
    mString = Replace(mString, CHR(13), "")
    mString = Replace(mString, CHR(10) & CHR(10), "</P><P> ")
    mString = Replace(mString, CHR(10), "<BR> ")


cc=replace(cc,chr(34),chr(39))  双引号换为单引号

详细Ascii码查询


2 window.frames////frames(i)集合对象的应用大全:
先有:
<frameset rows="*" cols="80,*" frameborder="NO" border="0" framespacing="0">
  <frame src="frameleft.htm" name="leftFrame" scrolling="NO" noresize>
  <frameset rows="80,*" frameborder="NO" border="0" framespacing="0">
    <frame src="frametop.htm" name="topFrame" scrolling="NO" noresize>
    <frame src="windowc.asp" name="mainFrame">
  </frameset>
</frameset>
<noframes><body>
</body></noframes>
在一个frame里面有这样判断:
<script language="javascript">
if ( window.parent.frames != null ) {
for ( i = 0; i< window.parent.frames.length; i++ )
window.alert ("子窗口 " +i+ " 的名称为 "+window.parent.frames(i).name);
}
</script>


 vb实现onclick事件:
<script language="vbscript">
sub button1_onClick()
 dim msgboxstatus
 msgboxstatus=msgbox ("选择按下的按钮",1+vbExclamation+vbDefaultButton2)
 msgbox(msgboxstatus)
end sub
</script>
<form>
<input type="button" name="button1" value="msgbox">
</form>


3 得到浏览器的位置信息:
function checkit()
{
   window.status="123";
   str+=("<br>IE距离屏幕左距离为:"+window.screenLeft);
   str+=("<br>IE距离屏幕顶距离为:"+window.screenTop);
   str+=("<br>设置默认状态栏文字为:"+window.defaultStatus);
   str+=("<br>设置状态栏文字为:"+window.status);
   str+=("<br>设置当前窗口名称为:"+window.name);
   showmsg.innerHTML=str;
}


4 document 对象
          集合:
All:返回对象所包含的元素集合的引用。
Anchors:获取所有带有 name 和/或 id 属性的 a 对象
的集合。此集合中的对象以 HTML 源顺序排列。
Forms:获取以源顺序排列的文档中所有 form 对象
的集合。
Frames:获取给定文档定义或与给定窗口关联的文档
定义的所有 window 对象的集合。

         方法:
Write:在指定窗口的文档中写入一个或多个 HTML
表达式。
Writeln:在指定窗口的文档中写入一个或多个
HTML 表达式,后面追加一个换行符。
Open:
1、只使用前两个参数 url 和 name。
该方法打开一个文档用于收集 write 和 writeln
方法的输出。
2、若指定了附加参数,此方法将打开一个窗口,
这与 window 对象的 window.open 方法相同。

 

6 .navigator 对象
           属性:
appCodeName获取浏览器的代码名称。
appMinorVersion获取应用程序的次版本值。
appName获取浏览器的名称。
appVersion获取浏览器运行的平台和版本。
browserLanguage获取浏览器的当前语言。


7 location 对象
 属性:
hash设置或获取 href 属性中在井号“#”后面的分段。
host设置或获取 location 或 URL 的
                                hostname 和 port 号码。
hostname设置或获取 location 或 URL 的主机名称部分。
href设置或获取整个 URL 为字符串。
pathname设置或获取对象指定的文件名或路径。
port设置或获取与 URL 关联的端口号码。
search设置或获取 href 属性中跟在问号后面的部分。
location.href='http://microsoft.com‘=
location='http://microsoft.com
 方法:
assign装入新的 HTML 文档。
reload重新装入当前页面。
replace装入指定 URL 的另外文档来替换当前文档。

8 screen 对象
 属性
availHeight获取系统屏幕的工作区域高度,
availWidth获取系统屏幕的工作区域宽度,
bufferDepth设置或获取用于画面外位图缓冲颜色的每像素位数。
colorDepth获取用于目标设置或缓冲区的颜色每像素位数。
deviceXDPI 设置或获取系统屏幕水平每英寸点数(DPI)的数值。
deviceYDPI 设置或获取系统屏幕垂直每英寸点数(DPI)的数值。
height获取屏幕的垂直分辨率。
width获取屏幕的水平分辨率。

##################################ASP内置对象##################################
1 request得到多个表单写法:
先有:
<input name="hobby" type="checkbox" value="电脑">电脑
  <input name="hobby" type="checkbox" value="游戏">游戏
  <input name="hobby" type="checkbox" value="体育">体育
  <input name="hobby" type="checkbox" value="阅读">阅读
处理是要得到就这样写了:
For I = 1 to Request.Form("hobby").Count
 Response.Write Request.Form("hobby")(I) & "<Br>"
Next


9 取得HTTP的cookie值
语法:request.Cookies(cookie)[.(关键字)|.haskeys
      Response.cookie(名称)[.(key).属性]=值

Contents集合
例子:
<%
Session("name")="董珂"
Session("genger")="男"
%>
这里Session对象的Contents集合一共有
<%=Session.Contents.Count%>项:<br>
<%
FOR I=1 to Session.Contents.Count
Response.Write("<br>"&Session.Contents(I))
NEXT
Session.Abandon
%>

删除保存在SESSION集合中的项
<% Session("myName") = " "
Session.Contents.Remove("myName")
%>
Session.Contents.Removeall()

删除保存在application集合中的项
Application("strFirst")=("First thing")
Application("strSecond")=("Second thing")
Application.Contents.Remove("strFirst")
application.Contents.Removeall()


#####################文件######################

FObject.CopyFile” c:/test/test.txt” “c:/test/test2.txt”
FObject.MoveFile” c:/test/test.txt” “c:/test/test3.txt”
FObject.DeleteFile” c:/test/test.txt”

Set fobject=server.createobject(“scripting.filesystemObject”)
Set tfile=fobject.CreateTextFile(“c:/test/test.txt”)
Tfile.writeLine(“ok写入文件”)
Tfile.close
Set afile=tfile.GetFile(“c:/test/test.txt”)
Afile.copy “c:/test2.txt”
Afile.move”c:/test3.txt”
Afile.delete

 

原创粉丝点击