/I.syk
_:oKJr1
创意公社- ideaer{ AcW#K j1oR
创意公社- ideaerC |h.D_h/u-H6K1 创建脚本块创意公社- ideaer'z&{N7qB,F@g!L
un^E0Dlwy1引用内容程序代码创意公社- ideaer
w"Is8nL
\5{+GW7D0wy
<script language=”JavaScript”>
Q8|r)z3\1
JavaScript 代码写在这里面
eb.^6q]6Ks1
</script>创意公社- ideaer,x9z G!SO1c@j
N\;tq"}z/yG/W12 隐藏脚本代码
N4G n_.e i ]1
引用内容程序代码
6B#wVeD7I1c1
<script language=”JavaScript”>
j3~kwAA(Ue1
<!–创意公社- ideaer3m&H"s,i%?iS-n
document.write(“Hello”);创意公社- ideaerF%b"W)mV'w QT5w
// –>
MEL#s&j/_N.V1
</script>
JW'R
px1
在不支持JavaScript的浏览器中将不执行相关代码
4P?s8z Xq!w.Q2_(o1
创意公社- ideaerW;c&qxm/M |3 浏览器不支持的时候显示
Tuj8A6lVn@K'CI"Y1
引用内容程序代码创意公社- ideaer;R(?FQ;wGK)f[5b7Ik
I
<noscript>
2Ws-^G$Wh\1
Hello to the non-JavaScript browser.
:B1X'?|V%Dc&XjT X1
</noscript>
"SB4bBy:C]-jz1
创意公社- ideaer ph`swPt4 链接外部脚本文件创意公社- ideaer#T
VOXt/~-T
引用内容程序代码
qEO@0y"z0y hU!V1
<script language=”JavaScript” src=”/”filename.js””></script>
`6S k:eJ
OfZ$P1
2u~;|h+[k.K15 注释脚本
P;Q};h\Y$e1
引用内容程序代码创意公社- ideaer h S!di:`cdtT0B
// This is a comment创意公社- ideaerv]j(ho{B)C
document.write(“Hello”); // This is a comment创意公社- ideaerXH-_%tJx
/*创意公社- ideaer9Uw-c;M&^cY~1A
All of this创意公社- ideaer0o'e
Mz"~/\'X
is a comment创意公社- ideaerx(I#rOFJ#d
*/创意公社- ideaer
P @U7R Q
创意公社- ideaer+V%m'o)c"e2w0b8CC3ww6 输出到浏览器创意公社- ideaerO2_;xz2p$Hf Y
引用内容程序代码
2O
I.uHt[#~1
document.write(“<strong>Hello</strong>”);创意公社- ideaer!b2UYjs8h
创意公社- ideaerhq;RR9UY?(DL+EI7 定义变量
U#uVQ P0Xw1
引用内容程序代码
l8XqD2vw@V(X1
var myVariable = “some value”;
2zvjB'u^x1
2Fh\0H G
Bb*L18 字符串相加
fx CYc6u*N1
引用内容程序代码创意公社- ideaerr1feU"tA'S
var myString = “String1” + “String2”;创意公社- ideaer1[+v{1`Aqzf
^cf/g[;G19 字符串搜索创意公社- ideaer(T}l x8UT^
引用内容程序代码创意公社- ideaer#bXZUSRu*C
<script language=”JavaScript”>创意公社- ideaerMK
YAUX)A
<!–
]O-SY)H1
var myVariable = “Hello there”;创意公社- ideaer_pQc.n&i~
var therePlace = myVariable.search(“there”);创意公社- ideaer9NVI%].G6j H
document.write(therePlace);创意公社- ideaer\/i!GET7S3}+?
// –>创意公社- ideaer5Y5uHXM
</script>创意公社- ideaer n#IZ1e;W;Y0A
LI
xIC |\5q110 字符串替换创意公社- ideaereJT1Av"y@y
引用内容程序代码
f&`O5avia1T1
thisVar.replace(“Monday”,”Friday”);
2_VO*a \6KG4P$JS M4I1
,]3q}uz6H1k111 格式化字串
E^
dE)i1
引用内容程序代码
Qt4{2h8L1
<script language=”JavaScript”>
6Cz B#E%i9x4dS A1
<!–
i4f*p@.R:NLv1
var myVariable = “Hello there”;创意公社- ideaerW2F-Nh B/I!~LX
G
b
document.write(myVariable.big() + “<br>”);创意公社- ideaer}b*tB;Zb&l/kN
document.write(myVariable.blink() + “<br>”);
8O3H1o#|R:k9e1
document.write(myVariable.bold() + “<br>”);创意公社- ideaerJK5E @0lk
document.write(myVariable.fixed() + “<br>”);