window.location.reload();刷新当前页面
parent.location.reload();刷新父级对象(用于框架)
opener.location.reload();刷新父窗口对象(用于单开窗口)
top.location.reload();刷新最顶端对象(用于多开窗口)
下面介绍一些javascript基本函数
1.document.write(“”);为输出语句
2.传统的html文档顺序是:document-》html-》(head,body)
3.浏览器窗口中的DOM顺序是:window-》(navigator,screen,history,location,document)
4.小写转大写的js:document.getElementById(“output”).value = document.getElementById(“input”).value.toUpperCase();
5.js的数据类型:string,number,Boolean,null,object,function
6.js的字符串转成数字:parseInt(),parseFloat();
7.数字转为字符串:(“”+变量)
8.循环的终止命令是break
9.窗口:打开窗口window.open(),关闭窗口:window.close(),窗口本身:self
10.状态栏的设置:window.status=”字符”;
11.弹出信息提示:window.alert(“字符”);
12.弹出确认框:window.confirm();
13.弹出输入提示框:window.prompt();
14.指定当前显示连接的位置:window.location.href = “URL”;
15.取出窗体中的所有表单的数量:document.forms.length;
16.关闭文档的输出流:document.close();
17.创建一个dom元素:document.createElement(),document.createTextNode();
18.指定在不支持脚本的浏览器显示的html:
19.当超链接和onclick事件都有时,则老版本的浏览器专向a.html,否则转向b.html,例如:
20.js的内建对象:有Array,Boolean,Date,Error,EvalError,Function,Math,Number,Object,RegExp,string,SyntaxError,TypeError,URLError
21.js中的换行:/n;
22.窗口全屏大小:
1 | <script> |
23.防止用户对文本框中输入文本:onfocus = “this.blur()”
24.取出某一元素在页面上出现的数量:document.all.tags(“div(或其他元素名)”).length;
25.js中分别为两种窗体输出:模态和非模态。window.showModelDialog(),window.showModeless();
26.状态栏文字的设置:window.status = ‘文字’,默认的状态栏文字设置:window.defaultStatus = ‘文字’;
27.添加到收藏夹:external.addFavorite(“http://www.google.com","google“);
28.js遇到错误脚本时不做任何操作:window.onerror = doNothing;指定错误句柄的语法为:window.onerror = handleError;
29.js中制定当前打开窗口的父窗口:window.opener,支持opener.opener…的多重继续
30.js的self指的是当前窗口
31.js中的top指的是框架集中最顶层的框架
32.js的窗口重定向:window.navigate(“http://www.google.com“);
33.js中的打印:window.print();
34.js中的提示输入框:window.prompt(“message”,”defaultReply”);
35.js中的窗口滚动条:window.scroll(x,y);
36.js中的窗口滚动位置:window.scrollby
37.js中的设置时间间隔:setInterval(“expr”,msecDelay)或setInterval(functionRef,mseDelay)或setTimeout;
38.js的模态显示在IE4+行,在NN行中不行:showModelDialog(“URL”,[arguments],[features]);
39.js中的退出之前使用的句柄:
1 | function verfyClose(){ |
40.当窗体第一次调用时使用onload();
41.当窗体关闭时调用的文件句柄:onunload();
42.window.location的属性:protocol(http),hostname(www.example.com),port(80),host(www.example.com:80),pathname(),hash(“#giantGizmo”,指跳转到相应的锚记),href(全部的信息);
43.window.location.reload()刷新当前页面;
44.parent.location.reload()刷新父级对象(用于框架)
45.opener.location.reload()刷新父窗口对象(用于单开窗口)
46.top.location.reload()刷新最顶端对象(用于多开窗口)
47.window.history.back()返回上一页,window.history.forward()返回下一页,window.history.go(返回第几页,也可以使用访问过的URL)
48.document.write()不换行的输出,document.writeIn()换行输出
49.document.body.noWrap = true; 防止链接文字折行
50.变量名.charAt(第几位),取该变量的第几位字符;
51.”abc”.charCodeAt(第几个),返回第几个字符的ASCII码值;
52.字符串连接:string.concat(sring2),或用+=进行连接
53.变量.indexOf(“字符”,起始位置),返回第一个出现的位置(从0开始计算)
54.string.lastIndexOf(searchString,startIndex)最后一次出现的位置
55.string.match(regExpression),判断字符是否匹配
56.string.replace(regExpression,replaceString)替换现有字符串
57.string.split(分隔符),返回一个数组存储值
58.string.substring(start,length)取从第几位到指定长度的字符串
59.parseInt(string)强制转化成整数
60.parseFloat()强制转换成浮点型,有小数点