js_常识

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

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

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

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

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

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

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

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

var form = window.document.forms[0] 

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

if (form.elements.type == "text "){ 

form.elements.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来开头后面加函数名 

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

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

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

53.JS中的换行:&#92;n 

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

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

57.innerHTML的值是表单元素的值:如 <p id= "para " > "how are <em >you </em > " </p >,则innerHTML的值就是:how are <em >you </em > ,innerTEXT的值和上面的一样,只不过不会把 <em >这种標记显示出来. 

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

60.isDisabled判定是否为禁止状態.disabled设置禁止状態 

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

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

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

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

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

69.状態栏文字的设置:window.status= &apos;文字 &apos;,默认的状態栏文字设置:window.defaultStatus = &apos;文字. &apos;; 

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

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

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

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

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.=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 

108. js 点击button 转到指定url: <input name="Submit" type="submit" class="button" value="返回" onClick="window.location.href('a.html')">

1. oncontextmenu="window.event.returnvalue=false" 将彻底屏蔽鼠标右键 

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

 

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

<script language="JavaScript">

 document.oncontextmenu=new Function("event.returnValue=false;"); //禁止右键功能,单击右键将无任何反应 

 document.onselectstart=new Function("event.returnValue=false;"); //禁止先择,也就是无法复制 

</script>

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"> 关闭输入法 

12.删除时确认 

<a href='"确实要删除吗?" location="boos.asp?&areyou=删除&page=1"'>删除</a> 

13. 取得控件的绝对位置 

<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=hh2.Click()> 

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

本例适用于IE 

 

17.屏蔽功能键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"> 

 

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);"> 

 

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.xxx.com">   

 

40.网页是否被检索 

<meta name="ROBOTS" content="属性值"> 

  其中属性值有以下一些: 

  属性值为"all": 文件将被检索,且页上链接可被查询; 

  属性值为"none": 文件不被检索,而且不查询页上的链接; 

  属性值为"index": 文件将被检索; 

  属性值为"follow": 查询页上的链接; 

  属性值为"noindex": 文件不检索,但可被查询链接; 

  属性值为"nofollow": 文件不被检索,但可查询页上的链接。  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值