js一些用法及几个常用的ASP代码

 

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.XXXXXX.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.οnlοad=beginrefresh

file://-->

</script>

 

11.ACCESS数据库连接:

<%

option explicit

dim startime,endtime,conn,connstr,db

startime=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 connstr

function CloseDatabase

Conn.close

Set conn = Nothing

End Function

%>

 

12.SQL数据库连接:

<%

option explicit

dim startime,endtime,conn,connstr,db

startime=timer()

connstr="driver={SQL Server};server=HUDENQ-N11T33NB;uid=sa;pwd=xsfeihu;database=dvbbs"

Set conn = Server.CreateObject("ADODB.Connection")

conn.Open connstr

function CloseDatabase

Conn.close

Set conn = Nothing

End 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 xxx></object></div> # 前面

<div z-Index:1><object xxx></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="clsid:D27CDB6E-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,FiletempData

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)

FiletempData = objCountFile.ReadAll

objCountFile.Close

FiletempData=Replace(FiletempData,Target,String)

Set objCountFile=objFSO.CreateTextFile(Server.MapPath(filename),True)

objCountFile.Write FiletempData

objCountFile.Close

Set objCountFile=Nothing

Set objFSO = Nothing

End Function

 

17.使用FSO读取文件内容的函数

function FSOFileRead(filename)

Dim objFSO,objCountFile,FiletempData

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")

Set objCountFile = objFSO.OpenTextFile(Server.MapPath(filename),1,True)

FSOFileRead = objCountFile.ReadAll

objCountFile.Close

Set objCountFile=Nothing

Set objFSO = Nothing

End Function

 

18.使用FSO读取文件某一行的函数

function FSOlinedit(filename,lineNum)

if linenum < 1 then exit function

dim fso,f,temparray,tempcnt

set fso = server.CreateObject("scripting.filesystemobject")

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.AtEndofStream then

tempcnt = f.readall

f.close

set f = nothing

temparray = split(tempcnt,chr(13)&chr(10))

if lineNum>ubound(temparray)+1 then

exit function

else

FSOlinedit = temparray(lineNum-1)

end if

end if

end function

 

19.使用FSO写文件某一行的函数

function FSOlinewrite(filename,lineNum,Linecontent)

if linenum < 1 then exit function

dim fso,f,temparray,tempCnt

set fso = server.CreateObject("scripting.filesystemobject")

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.AtEndofStream then

tempcnt = f.readall

f.close

temparray = split(tempcnt,chr(13)&chr(10))

if lineNum>ubound(temparray)+1 then

exit function

else

temparray(lineNum-1) = lineContent

end if

tempcnt = join(temparray,chr(13)&chr(10))

set f = fso.createtextfile(server.mappath(filename),true)

f.write tempcnt

end if

f.close

set f = nothing

end function

 

20.使用FSO添加文件新行的函数

function FSOappline(filename,Linecontent)

dim fso,f

set fso = server.CreateObject("scripting.filesystemobject")

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),8,1)

f.write chr(13)&chr(10)&Linecontent

f.close

set f = nothing

end function

 

21.读文件最后一行的函数

function FSOlastline(filename)

dim fso,f,temparray,tempcnt

set fso = server.CreateObject("scripting.filesystemobject")

if not fso.fileExists(server.mappath(filename)) then exit function

set f = fso.opentextfile(server.mappath(filename),1)

if not f.AtEndofStream then

tempcnt = f.readall

f.close

set f = nothing

temparray = split(tempcnt,chr(13)&chr(10))

FSOlastline = temparray(ubound(temparray))

end if

end function

>>>---------我想分页!--这么长的文章,在这里来个分页多好啊!哈哈----------<<<

1. οncοntextmenu="window.event.returnValue=false" 将彻底屏蔽鼠标右键

<table border οncοntextmenu=return(false)><td>no</table> 可用于Table

 

2. <body onselectstart="return false"> 取消选取、防止复制

 

3. οnpaste="return false" 不准粘贴

 

4. οncοpy="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=查看网页源代码

οnclick="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,b

set a=document.all.img1

t=document.all.img1.offsetTop

l=document.all.img1.offsetLeft

while a.tagName<>"BODY"

set a = a.offsetParent

t=t+a.offsetTop

l=l+a.offsetLeft

wend

msgbox "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" οnfοcus="cc()">

 

15. 判断上一页的来源

javascript :document.referrer

 

16. 最小化、最大化、关闭窗口

<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=最小化 οnclick=hh1.Click()>

<input type=button value=最大化 οnclick=hh2.Click()>

<input type=button value=关闭 οnclick=hh3.Click()>

本例适用于IE

 

17.屏蔽功能键Shift,Alt,Ctrl

<script>

function look(){

if(event.shiftKey)

alert("禁止按Shift键!"); //可以换成ALT CTRL

}

document.οnkeydοwn=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 οnblur="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 οnlοad="top.resizeTo(300,200);">

打开页面的位置<body οnlοad="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.clientHeight

 

30. 怎么判断是否是字符

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 * 1000

a = 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 radio1

if ob.checked then window.alert ob.value

next

end 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" οnclick="checkme()">

</BODY></HTML>

 

34.脚本永不出错

<SCRIPT LANGUAGE="JavaScript">

<!-- Hide

function killErrors() {

return true;

}

window.onerror = killErrors;

// -->

</SCRIPT>

 

35.ENTER键可以让光标移到下一个输入框

<input οnkeydοwn="if(event.keyCode==13)event.keyCode=9">

 

36. 检测某个网站的链接速度:

把如下代码加入<body>区域中:

<script language=Javascript>

tim=1

setInterval("tim++",100)

b=1

var 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

 

οnclick=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=url

if(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

 

οnerrοr=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-resize

n-resize

nw-resize

w-resize

s-resize

se-resize

sw-resize

 

38.页面进入和退出的特效

进入页面<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": 文件不被检索,但可查询页上的链接。

>>>---------我想分页!--这么长的文章,在这里来个分页多好啊!哈哈----------<<<

js宝典学习笔记ZT 

 

每一项都是js中的小技巧,但十分的实用! 

1.document.write(""); 输出语句

2.JS中的注释为//

3.传统的HTML文档顺序是:document->html->(head,body)

4.一个浏览器窗口中的DOM顺序是:window->(navigator,screen,history,location,document)

5.得到表单中元素的名称和值:document.getElementById("表单中元素的ID号").name(或value)

6.一个小写转大写的JS: document.getElementById("output").value = document.getElementById("input").value.toUpperCase();

7.JS中的值类型:String,Number,Boolean,Null,Object,Function

8.JS中的字符型转换成数值型:parseInt(),parseFloat()

9.JS中的数字转换成字符型:(""+变量)

10.JS中的取字符串长度是:(length)

11.JS中的字符与字符相连接使用+号.

12.JS中的比较操作符有:==等于,!=不等于,>,>=,<.<=

13.JS中声明变量使用:var来进行声明

14.JS中的判断语句结构:if(condition){}else{}

15.JS中的循环结构:for([initial expression];[condition];[upadte expression]) {inside loop}

16.循环中止的命令是:break

17.JS中的函数定义:function functionName([parameter],...){statement[s]}

18.当文件中出现多个form表单时.可以用document.forms[0],document.forms[1]来代替.

19.窗口:打开窗口window.open(), 关闭一个窗口:window.close(), 窗口本身:self

20.状态栏的设置:window.status="字符";

21.弹出提示信息:window.alert("字符");

22.弹出确认框:window.confirm();

23.弹出输入提示框:window.prompt();

24.指定当前显示链接的位置:window.location.href="URL"

25.取出窗体中的所有表单的数量:document.forms.length

26.关闭文档的输出流:document.close();

27.字符串追加连接符:+=

28.创建一个文档元素:document.createElement(),document.createTextNode()

29.得到元素的方法:document.getElementById()

30.设置表单中所有文本型的成员的值为空:

var form = window.document.forms[0]

for (var i = 0; i<form.elements.length;i++){

if (form.elements[i].type == "text"){

form.elements[i].value = "";

}

}

31.复选按钮在JS中判断是否选中:document.forms[0].checkThis.checked (checked属性代表为是否选中返回TRUE或FALSE)

32.单选按钮组(单选按钮的名称必须相同):取单选按钮组的长度document.forms[0].groupName.length

33.单选按钮组判断是否被选中也是用checked.

34.下拉列表框的值:document.forms[0].selectName.options[n].value (n有时用下拉列表框名称加上.selectedIndex来确定被选中的值)

35.字符串的定义:var myString = new String("This is lightsword");

36.字符串转成大写:string.toUpperCase(); 字符串转成小写:string.toLowerCase();

37.返回字符串2在字符串1中出现的位置:String1.indexOf("String2")!=-1则说明没找到.

38.取字符串中指定位置的一个字符:StringA.charAt(9);

39.取出字符串中指定起点和终点的子字符串:stringA.substring(2,6);

40.数学函数:Math.PI(返回圆周率),Math.SQRT2(返回开方),Math.max(value1,value2)返回两个数中的最在值,Math.pow(value1,10)返回value1的十次方,Math.round(value1)四舍五入函数,Math.floor(Math.random()*(n+1))返回随机数

41.定义日期型变量:var today = new Date();

42.日期函数列表:dateObj.getTime()得到时间,dateObj.getYear()得到年份,dateObj.getFullYear()得到四位的年份,dateObj.getMonth()得到月份,dateObj.getDate()得到日,dateObj.getDay()得到日期几,dateObj.getHours()得到小时,dateObj.getMinutes()得到分,dateObj.getSeconds()得到秒,dateObj.setTime(value)设置时间,dateObj.setYear(val)设置年,dateObj.setMonth(val)设置月,dateObj.setDate(val)设置日,dateObj.setDay(val)设置星期几,dateObj.setHours设置小时,dateObj.setMinutes(val)设置分,dateObj.setSeconds(val)设置秒 [注意:此日期时间从0开始计]

43.FRAME的表示方式: [window.]frames[n].ObjFuncVarName,frames["frameName"].ObjFuncVarName,frameName.ObjFuncVarName

44.parent代表父亲对象,top代表最顶端对象

45.打开子窗口的父窗口为:opener

46.表示当前所属的位置:this

47.当在超链接中调用JS函数时用:(javascript :)来开头后面加函数名

48.在老的浏览器中不执行此JS:<!-- //-->

49.引用一个文件式的JS:<script type="text/javascript" src="aaa.js"></script>

50.指定在不支持脚本的浏览器显示的HTML:<noscript></noscript>

51.当超链和ONCLICK事件都有时,则老版本的浏览器转向a.html,否则转向b.html.例:<a href="a.html" οnclick="location.href='b.html';return false">dfsadf</a>

52.JS的内建对象有:Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RangeError,ReferenceError,RegExp,String,SyntaxError,TypeError,URIError

53.JS中的换行:/n

54.窗口全屏大小:<script>function fullScreen(){ this.moveTo(0,0);this.outerWidth=screen.availWidth;this.outerHeight=screen.availHeight;}window.maximize=fullScreen;</script>

55.JS中的all代表其下层的全部元素

56.JS中的焦点顺序:document.getElementByid("表单元素").tabIndex = 1

57.innerHTML的值是表单元素的值:如<p id="para">"how are <em>you</em>"</p>,则innerHTML的值就是:how are <em>you</em>

58.innerTEXT的值和上面的一样,只不过不会把<em>这种标记显示出来.

59.contentEditable可设置元素是否可被修改,isContentEditable返回是否可修改的状态.

60.isDisabled判断是否为禁止状态.disabled设置禁止状态

61.length取得长度,返回整型数值

62.addBehavior()是一种JS调用的外部函数文件其扩展名为.htc

63.window.focus()使当前的窗口在所有窗口之前.

64.blur()指失去焦点.与FOCUS()相反.

65.select()指元素为选中状态.

66.防止用户对文本框中输入文本:οnfοcus="this.blur()"

67.取出该元素在页面中出现的数量:document.all.tags("div(或其它HTML标记符)").length

68.JS中分为两种窗体输出:模态和非模态.window.showModaldialog(),window.showModeless()

69.状态栏文字的设置:window.status='文字',默认的状态栏文字设置:window.defaultStatus = '文字.';

70.添加到收藏夹:external.AddFavorite("http://www.dannyg.com","jaskdlf");

71.JS中遇到脚本错误时不做任何操作:window.onerror = doNothing; 指定错误句柄的语法为:window.onerror = handleError;

72.JS中指定当前打开窗口的父窗口:window.opener,支持opener.opener...的多重继续.

73.JS中的self指的是当前的窗口

74.JS中状态栏显示内容:window.status="内容"

75.JS中的top指的是框架集中最顶层的框架

76.JS中关闭当前的窗口:window.close();

77.JS中提出是否确认的框:if(confirm("Are you sure?")){alert("ok");}else{alert("Not Ok");}

78.JS中的窗口重定向:window.navigate("http://www.sina.com.cn");

79.JS中的打印:window.print()

80.JS中的提示输入框:window.prompt("message","defaultReply");

81.JS中的窗口滚动条:window.scroll(x,y)

82.JS中的窗口滚动到位置:window.scrollby

83.JS中设置时间间隔:setInterval("expr",msecDelay)或setInterval(funcRef,msecDelay)或setTimeout

84.JS中的模态显示在IE4+行,在NN中不行:showModalDialog("URL"[,arguments][,features]);

85.JS中的退出之前使用的句柄:function verifyClose(){event.returnValue="we really like you and hope you will stay longer.";}} window.οnbefοreunlοad=verifyClose;

86.当窗体第一次调用时使用的文件句柄:onload()

87.当窗体关闭时调用的文件句柄:onunload()

88.window.location的属性: protocol(http:),hostname(www.example.com),port(80),host(www.example.com:80),pathname("/a/a.html"),hash("#giantGizmo",指跳转到相应的锚记),href(全部的信息)

89.window.location.reload()刷新当前页面.

90.window.history.back()返回上一页,window.history.forward()返回下一页,window.history.go(返回第几页,也可以使用访问过的URL)

91.document.write()不换行的输出,document.writeln()换行输出

92.document.body.noWrap=true;防止链接文字折行.

93.变量名.charAt(第几位),取该变量的第几位的字符.

94."abc".charCodeAt(第几个),返回第几个字符的ASCii码值.

95.字符串连接:string.concat(string2),或用+=进行连接

96.变量.indexOf("字符",起始位置),返回第一个出现的位置(从0开始计算)

97.string.lastIndexOf(searchString[,startIndex])最后一次出现的位置.

98.string.match(regExpression),判断字符是否匹配.

99.string.replace(regExpression,replaceString)替换现有字符串.

100.string.split(分隔符)返回一个数组存储值.

101.string.substr(start[,length])取从第几位到指定长度的字符串.

102.string.toLowerCase()使字符串全部变为小写.

103.string.toUpperCase()使全部字符变为大写.

104.parseInt(string[,radix(代表进制)])强制转换成整型.

105.parseFloat(string[,radix])强制转换成浮点型.

106.isNaN(变量):测试是否为数值型.

107.定义常量的关键字:const,定义变量的关键字:var 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值