JS小知识

输出语句####

1.document.write( " ");```
####传统的HTML文档顺序是####
```html
document- >html- >(head,body)```
####一个浏览器窗口中的DOM顺序是####
```html
window- >(navigator,screen,history,location,document)```
####得到表单中元素的名称和值####
```html
document.getElementById( "表单中元素的ID號 ").name(或value) ```
####一个小写转大写的JS####
```html
 document.getElementById( "output ").value =document.getElementById( "input ").value.toUpperCase();```
####JS中的值类型####
```html
String,Number,Boolean,Null,Object,Function```
####JS中的字符型转换成数值型####
```html
parseInt(),parseFloat()```
####JS中的数字转换成字符型####
( " " 变量)
***
####JS中的取字符串长度是####
(length).
***
####JS中的字符与字符相连接使用 號####
.
***
####.JS中的比较操作符有####
==等于,!=不等于, >, >=, <. <=
***
####.JS中声明变量使用####
var来进行声明
***
####JS中的判定语句结构####
if(condition){}else{}
***
####.JS中的循环结构####
for([initial expression];[condition];[upadte expression]) {inside loop
***
####.循环中止的命令是####
break
***
####.JS中的函数定义####
function functionName([parameter],...){statement[s]}
***
####当文件中出现多个form表单时####
可以用document.forms[0],document.forms[1]来代替
***
####窗口####
打开窗口window.open(), 关闭一个窗口:window.close(), 窗口本身:self
***
####.状態栏的设置####
window.status= "字符 ";
***
####弹出提示信息####
window.alert( "字符 ")
***
####弹出確认框####
window.confirm();
***
####弹出输入提示框####
window.prompt()
***
####指定当前显示链接的位置####
window.location.href= "URL "
***
####取出窗体中的所有表单的数量####
document.forms.length
***
####关闭文档的输出流####
document.close();
***
####字符串追加连接符####
 =
***
####创建一个文档元素####
document.createElement(),document.createTextNode()
***
####得到元素的方法####
document.getElementById()
***
####设置表单中所有文本型的成员的值为空####
var form = window.document.forms[0]for (var i = 0; i49.引用一个文件式的JS
***
####指定在不支持脚本的浏览器显示的HTML####
####.当超链和onCLICK事件都有时,则老版本的浏览器转向a.html,否则转向b.html.####例:[dfsadf](http://www.jianshu.com/a.html)
***
####JS的內建对象有####
```html
Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RangeError,ReferenceError,RegExp,String,SyntaxError,TypeError,URIError```
####JS中的换行####
\n
####窗口全屏大小####
```html
function fullScreen(){ this.moveTo(0,0);this.outerWidth=screen.availWidth;this.outerHeight=screen.availHeight;}window.maximize=fullScreen```
####JS中的all代表其下层的全部元素56.JS中的焦点顺序####
document.getElementByid( "表单元素 ").tabIndex = 157.innerHTML的值是表单元素的值:如

"how are*you*"
,则innerHTML的值就是:how are*you 这种標记显示出来.59.contentEditable可设置元素是否可被修改,isContentEditable返回是否可修改的状態.
***
####isDisabled判定是否为禁止状態.disabled设置禁止状態*####
***
####length取得长度,返回整型数值
***
####addBehavior()是一种JS调用的外部函数文件其扩展名为.htc
***
####window.focus()使当前的窗口在所有窗口之前
***
####blur()指失去焦点.与FOCUS()相反.
***
####select()指元素为选中状態.
***
####防止用户对文本框中输入文本:
***
####取出该元素在页面中出现的数量:document.all.tags( "div(或其它HTML標记符) ").length
***
####JS中分为两种窗体输出:模態和非模態.window.showModaldialog(),window.showModeless()
***
####状態栏文字的设置:window.status= '文字 ',默认的状態栏文字设置:window.defaultStatus = '文字. ';
***
####添加到收藏夹:external.AddFavorite( "http://www.dannyg.com ";, "jaskdlf ");
***
####JS中碰到脚本错误时不做任何操作:window.onerror = doNothing; 指定错误句柄的语法
为:window.onerror = handleError;
***
####JS中指定当前打开窗口的父窗口:window.opener,支持opener.opener...的多重继续
***
####JS中的self指的是当前的窗口
***
####JS中状態栏显示內容:window.status= "內容 "
***
####JS中的top指的是框架集中最顶层的框架
***
####JS中关闭当前的窗口:window.close();
***
####JS中提出是否確认的框:if(confirm( "Are you sure? ")){alert( "ok ");}else{alert( "Not Ok ");}
***
####JS中的窗口重定向:window.navigate( "http://www.sina.com.cn ";);
***
####JS中的打印:window.print()
***
####JS中的提示输入框:window.prompt( "message ", "defaultReply ");
***
####JS中的窗口滚动条:window.scroll(x,y)
***
####JS中的窗口滚动到位置:window.scrollby
***
####JS中设置时间间隔:setInterval( "expr ",msecDelay)或setInterval(funcRef,msecDelay)或setTimeout
***
####JS中的模態显示在IE4 行,在NN中不行:showModalDialog( "URL "[,arguments][,features]);
***
####JS中的退出之前使用的句柄:function verifyClose(){event.returnValue= "we really like you and hope you will stay longer. ";}}
window.=verifyClose;
***
####当窗体第一次调用时使用的文件句柄:onload()
***
####当窗体关闭时调用的文件句柄:onunload()
***
####window.location的属性: protocol(http:),hostname(www.example.com),port(80),host(www.example.com:80),pathname
( "/a/a.html "),hash( "#giantGizmo ",指跳转到相应的锚记),href(全部的信息)
***
####window.location.reload()刷新当前页面.
***
####window.history.back()返回上一页,window.history.forward()返回下一页,window.history.go(返回第几页,也可以使用访问过的URL)
***
####document.write()不换行的输出,document.writeln()换行输出
***
####document.body.noWrap=true;防止链接文字折行.
***
####变量名.charAt(第几位),取该变量的第几位的字符.
***
#### "abc ".charCodeAt(第几个),返回第几个字符的ASCii码值.
***
####字符串连接:string.concat(string2),或用 =进行连接
***
####变量.indexOf( "字符 ",起始位置),返回第一个出现的位置(从0开始计算)
***
####string.lastIndexOf(searchString[,startIndex])最后一次出现的位置.
***
####string.match(regExpression),判定字符是否匹配.
***
####string.replace(regExpression,replaceString)替换现有字符串.
***
####string.split(分隔符)返回一个数组存储值.
***
####string.substr(start[,length])取从第几位到指定长度的字符串.
***
####string.toLowerCase()使字符串全部变为小写.
***
####string.toUpperCase()使全部字符变为大写.
***
####parseInt(string[,radix(代表进制)])强制转换成整型.
***
####parseFloat(string[,radix])强制转换成浮点型.
***
####isNaN(变量):测试是否为数值型.
***
####定义常量的要害字:const,定义变量的要害字:var####
***

你可能感兴趣的:(JS小知识)