Home > Article > Web Front-end > What are the commonly used attribute methods in JavaScript?
Commonly used attribute methods in JavaScript include: 1. The comment in JS is [//]; 2. Convert character type to numeric type [parseInt()]; 3. Get the length of the string [length]; 4. Use var to declare variables; 5. Judgment statement structure [if(condition){}else{}].
The operating environment of this tutorial: Windows 7 system, JavaScript version 1.8.5, DELL G3 computer.
Commonly used attribute methods in JavaScript are:
1.document.write(""); Output statement
2. The comment in JS is/ /
3. The traditional HTML document sequence is: document->;html->(head,body)
4. The DOM sequence in a browser window is: window ->;(navigator,screen,history,location,document)
5. Get the name and value of the element in the form: document.getElementById("ID number of the element in the form").name (or value )
6. A lowercase to uppercase JS:
document.getElementById("output").value=document.getElementById("input").value.toUpperCase();
7. Value types in JS: String, Number, Boolean, Null, Object, Function
8. Convert character types into numerical types in JS: parseInt(), parseFloat()
9. Convert numbers in JS to character type: ("" variable)
10. Get the string length in JS: (length)
11.JS Characters are connected with characters using numbers.
12. The comparison operators in JS are: ==Equal,!=Not equal,>;,>;=,38212ba0f1824838f84f767ebb02658c;
49.引用一个文件式的JS:e3bc8d4cbc25908b0b861b5a26d7afd8;2cacc6d41bbb37262a98f745aa00fbf0;
50.指定在不支持脚本的浏览器显示的HTML:2b0b25ff593c5b6c03403dd6234ffb2c;3f1c4e4b6b16bbbd69b2ee476dc4f83a;
51.当超链和onCLICK事件都有时,则老版本的浏览器转向a.html,否则转向b.html.
例:
<a href="a.html" onclick="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的值是表单元素的值:
如cdb42d3cccacfe7e9fc1bf128ba82480;"how are 907fae80ddef53131f3292ee4f81644b;youd1c6776b927dc33c5d9114750b586338;"94b3e26ee717c64999d7867364b1b4a3;,则innerHTML的值就是:how are 907fae80ddef53131f3292ee4f81644b;youd1c6776b927dc33c5d9114750b586338;
58.innerTEXT的值和上面的一样,只不过不会把907fae80ddef53131f3292ee4f81644b;这种标记显示出来.
59.contentEditable可设置元素是否可被修改,isContentEditable返回是否可修改的状态.
60.isDisabled判断是否为禁止状态.disabled设置禁止状态
61.length取得长度,返回整型数值
62.addBehavior()是一种JS调用的外部函数文件其扩展名为.htc
63.window.focus()使当前的窗口在所有窗口之前.
64.blur()指失去焦点.与FOCUS()相反.
65.select()指元素为选中状态.
66.防止用户对文本框中输入文本: onfocus="this.blur()"
67.取出该元素在页面中出现的数量: document.all.tags("div(或其它HTML标记符)").length
68.JS中分为两种窗体输出:模态和非模态. window.showModaldialog(),window.showModeless()
69.状态栏文字的设置:
window.status='文字',默认的状态栏文字设置:window.defaultStatus = '文字.';
70.添加到收藏夹:
external.AddFavorite("http://meil.cnblogs.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://meil.cnblogs.com";);
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()刷新当前页面.
parent.location.reload()刷新父亲对象(用于框架).
opener.location.reload()刷新父窗口对象(用于单开窗口).
top.location.reload() refreshes the top object (for multiple windows)
90.window.history.back() returns to the previous One page, window.history.forward() returns to the next page,
window.history.go (return to which page, you can also use the visited URL)
91.document. write() does not wrap the output, document.writeln() wraps the output
92.document.body.noWrap=true; prevents the link text from wrapping.
93.Variable name.charAt( Which number), takes the character of the variable.
94. "abc".charCodeAt (what number), returns the ASCii code value of the character.
95. String connection: string.concat(string2), or use = to connect
96. Variable.indexOf("Character", starting position), returns the first occurrence position (starting from 0 Calculate)
97.string.lastIndexOf(searchString[,startIndex])The last occurrence position.
98.string.match(regExpression), determine whether the characters match.
99.string.replace(regExpression,replaceString) replaces the existing string.
100.string.split(separator) returns an array to store the value.
101.string.substr (start[,length]) takes the string from the digit to the specified length.
102.string.toLowerCase() makes the string all lowercase.
103.string. toUpperCase() makes all characters uppercase.
104.parseInt(string[,radix(representing base)]) is forced to be converted to an integer type.
105.parseFloat(string[, radix]) is forced to convert to a floating point type.
106.isNaN (variable): Test whether it is a numeric type.
107. Keywords for defining constants: const, keywords for defining variables :var
Related free learning recommendations: javascript video tutorial
The above is the detailed content of What are the commonly used attribute methods in JavaScript?. For more information, please follow other related articles on the PHP Chinese website!