[转载]Javascript 常用属性


[转载]Javascript 常用属性
2011年05月13日
  //                 单行注释
            对不支持JavaScript的浏览器隐藏代码
  n                 换行
  r                 回车
  t                 制表符
  b                 后退
  f                
  '                 单引号
  "                 双引号
  &                 与符号
  \                 反斜线
  本行未完,下行续
  opener             打开子窗口的父窗口
  this               表示当前所属的位置
  top                框架集中最顶层的框架 代表最顶端对象
  parent             代表父亲对象 
  blur()             失去焦点
  focus()            得到焦点
  select()           元素为选中状态
  onload()           窗体第一次调用时使用的文件句柄
  onunload()         窗体关闭时调用的文件句柄
  length()           取字符串长度
  isNaN(变量)        测试是否为数值型.   
  alert("Hellow")    弹出对话框
  confirm(“RIGHT”)   确认对话框
  prompt(“Write”)    输入对话框
  定义常量的关键字:const
  定义变量的关键字:var  
  JS中的函数定义:  function functionName([parameter],...){statement[s]}
  定义日期型变量:  var today = new Date()
  定义字符串变量:  var myString = new String("This is lightsword")  
  JS中的焦点顺序:  document.getElementByIdx("表单元素").tabIndex = 1
  document->html->(head,body)                           传统的HTML文档顺序
  window->(navigator,screen,history,location,document )  浏览器窗口中的DOM顺序是
  7.JS中的值类型: String,Number,Boolean,Null,Object,Function
  57.innerHTML的值是表单元素的值:
  如"how are you",则innerHTML的值就是:how are you
  58.innerTEXT的值和上面的一样,只不过不会把这种标记显示出来.
  59.contentEditable可设置元素是否可被修改,isContentEditable返回是否可修改的状态.
  66.防止用户对文本框中输入文本:
  onfocus="this.blur()"
  70.添加到收藏夹:
  external.AddFavorite("http://meil.livebaby.com";," meil");
  JS中提出是否确认的框:
  if(confirm("Are you sure?"))
  {
  alert("ok");
  }
  else
  {
  alert("Not Ok");
  }
  83.JS中设置时间间隔:setInterval("expr",msecDelay)或setInterval(funcRef,msecDelay)或setTimeout
  84.JS中的模态显示在IE4 行,在NN中不行:showModalDialog("URL"[,arguments][,features]);
  85.JS中的退出之前使用的句柄:
  function verifyClose(){event.returnvalue="/blog/we really like you and hope you will stay longer.";}} window.=verifyClose;
  88.window.location的属性:
  protocol(http:),hostname(www.example.com),port(80) ,host(www.example.com:80),
  pathname("/a/a.html"),hash("#giantGizmo",指跳转到相应的锚记),href(全部的信息)
  30.设置表单中所有文本型的成员的值为空:
  var form = window.document.forms[0]
  for (var i = 0; i
  指定在不支持脚本的浏览器显示的HTML:
  
  当超链和onCLICK事件都有时
  老版本的浏览器转向a.html,否则转向b.html.
  例:dfsadf
  窗口全屏大小:
  
  function fullScreen()
  {
  this.moveTo(0,0);
  this.outerWidth=screen.availWidth;
  this.outerHeight=screen.availHeight;     }     window.maximize=fullScreen;      JS的内建对象
  Array          数组
  Boolean        布尔型
  Date           日期型
  Error
  EvalError      异常
  Function       函数
  Math           数学
  Number         数值
  Object         对象
  RangeError     越界错误
  ReferenceError 刷新错误
  RegExp
  String         字符串
  SyntaxError    语法错误
  TypeError      类型错误
  URIError       链接错误
  窗口
  window.open()                                打开窗口
  window.close()                               关闭当前窗口
  self                                         指的是当前的窗口
  all                                          代表其下层的全部元素
  window.status="字符"                         状态栏显示内容 
  window.alert("字符")                         弹出提示信息
  window.confirm()                             弹出确认框
  window.prompt()                              弹出输入提示框
  window.location.href="/blog/URL"             指定当前显示链接的位置
  window.location.reload()                     刷新当前页面.
  window.history.back()                        返回上一页
  window.history.forward()                     返回下一页,
  window.history.go                            (返回第几页,也可以使用访问过的URL)
  window.print()                               JS中的打印
  window.navigate(http://meil.cnblogs.com;);   窗口重定向
  window.prompt("message","defaultReply");     提示输入框
  window.scroll(x,y)                           窗口滚动条
  window.scrollby                              窗口滚动到位置
  window.defaultStatus = '文字.'               默认的状态栏文字设置
  window.focus()                               使当前的窗口在所有窗口之前
  window.onerror = doNothing                   遇到脚本错误时不做任何操作
  window.onerror = handleError                 遇到脚本错误时指定错误句柄
  window.opener                                指定当前打开窗口的父窗口
  window.opener.opener...                      多重继续
  文档
  document.write("")                           输出语句 不换行的输出
  document.writeln()                           换行输出
  document.getElementByIdx()                    得到元素的方法
  document.getElementByIdx("ID号").name         得到表单中元素的名称
  document.getElementByIdx("ID号").value        得到表单中元素的值
  document.forms.length                        取出窗体中的所有表单的数量
  document.close()                             关闭文档的输出流
  document.createElement()                     创建一个文档元素
  document.createTextNode()                    创建一个文档元素 
  document.body.noWrap=true                    防止链接文字折行.
  document.forms[0](forms[1])                  文件中出现多个form表单时 指出方式
  document.all.tags("div(OR 其它)").length     该元素在页面中出现的数量
  window.showModaldialog()                     模态窗体输出
  window.showModeless()                        非模态窗体输出
  类型转换
  parseInt(string[,radix(代表进制)])             强制转换成整型.
  parseFloat(string[,radix])                    强制转换成浮点型.
  parseInt()                                    字符型转换成数值型
  parseFloat()                                  字符型转换成数值型

猜你喜欢

转载自ook03ook.iteye.com/blog/1359658
今日推荐