⊄
⊄
⊄
⊄
this.property
<html xmlns=" /><
head>
<
title></title>
<
script language= "JavaScript" type="text/javascript">
function
displayName(name) {
alert(
"Xin chào " + name); }
</script>
</
head>
<
body>
<
form name="myform" method="get">
<
input type="text" name="ten" value="Nhập tên"
onchange="displayName(form.test.value)" />
</
form>
</
body>
</
html>
⊄
for (variable in Object) {
<các câu lệnh>;}
<script language= "JavaScript" type="text/javascript">
color = new Array("red","blue","green")
for (cl in color) {
document.write(color[cl]);
document.write(
"<hr color='"+color[cl]+ "'/>");
}
</script>
⊄
with (Object) {
<các câu lệnh>;}
⊄
<script language="javascript" type="text/javascript">
var
a, b, c;
var r = 10;
with (Math) {
a = PI * r * r;
b = r * cos(PI);
c = r * sin(PI / 2);}
document.write(a +
"<br/>");
document.write(b +
"<br/>");
document.write(c +
"<br/>");
</script>
⊄
objectName= new ObjectType(para1[,para2, );
<script language="javascript" type="text/javascript">
function
employee(name, code) {
this.name = name;
this.code = code; }
var myemp = new employee("Nguyễn Văn Hòa",
"EM03");
document.write(
"<br/> Họ tên:" + myemp.name);
document.write(
"<br/> Mã nhân viên: " + myemp.code);
</script>
⊄
eval(string);
<script language="javascript" type="text/javascript">
var
x = 10;
var y = 5;
document.write(eval(
"x+y*3"));
</script>
stringName.propertyName;
⊄
var str = "Xin chào";
⊄
str = "Xin chào";
⊄
var str = String("Xin chào“);
stringName.length: độ dài của chuỗi.
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
<script language="javascript"
type="text/javascript">
var
str = String("Xin chào");
document.write(str.length);
document.write(str.big());
document.write(str.blink());
document.write(str.fontcolor(
"#FFBBDD"));
document.write(str.strike());
document.write(str.sub());
</script>
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
<html xmlns=" /><
head>
<
title></title>
<
script language="javascript" type="text/javascript">
function
dientich(r) {
var s;
s = Math.PI * r * r;
myform.txtKQ.value = s; }
</script>
</
head>
<
body>
<
form id="myform" >
<
input type="text" name="txtR" />
<
input type="button" name="cmdTinh" value="Tính" onclick="dientich(myform.txtR.value)"/>
<
input type="text" name="txtKQ" />
</
form>
</
body>
</
html>
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
⊄
<html>
<
head>
<
title>DOM Example</title>
<
script type="text/javascript" language="javascript">
var
oHtml = document.documentElement;
var oHead = oHtml.firstChild;
var oBody = oHtml.lastChild;
alert(oHead.nodeName);
//outputs “HEAD”
alert(oBody.parentNode == oHtml); //outputs “true”
</script>
</
head>
<
body>
<
p>Hello World!</p>
<
p>You’re learning to use the DOM!</p>
</
body>
</
html>
⊄
⊄
⊄
⊄
⊄
⊄
<script type="text/javascript"
language="javascript">
alert(document.title);
</script>