?????? ??
??????? ??????
JavaScript? ????? ? ???(????) ??? ?? ???? ???? ???, ??? ??? ??? ???? ? HTML ? ???? ?? ??? ???? ? ?????.
JavaScript? ?? ??? ?? ?? ? ??? ?? ???? ??? ???? ?? ? ?????? ?????.
JavaScript? ?? Sun Corporation? ?? ?????. ?? ?? ??? Javascript? Ecma International(? European Computer Manufacturer Association)? ECMA-262 ??(ECMAScript)? ??? ?????. ?? ?? ????.
JavaScript ??
???? ??
JavaScript? ?? ???? ????? ???? ?????? ???? ???? ?????. ?? ???? ??? ????? JavaScript? ?????? ??? ? ? ?? ???? ?? ?????.
?? ?? ??
JavaScript? ?? ?? ???? ?? ???? ??? ?? ????. ?, ??? ?? ??? ??? ? ??? ?????. ??? ???? ??? ?? ???? ????? ?? ??? ?? ?? ??? ??? ? ????.
Simplicity
JavaScript ??? ?? ?????. ?? ?? ??? ??? ??? ??? ??? ???? ??? JavaScript ????? ??? ? ????. ???? ???? ??? ?? ??? ?? ?? ??? ??? ??? ?? ??? ???? ????.
Security
JavaScript? ?? ??? ?? ?? ???? ?? ???? ???? ???, ???? ??? ?? ? ??? ?????. ????? ?? ????? ?? ???? ?? ?? ??? ???? ??? ??? ????? ??? ? ????.
Dynamics
JavaScript? ????? ? ??? ????? ??? ?? ??? ??? ?? ??? ? ????. ??? ?? ???? ????? ?????. ?? ??? ???? ? ????? ?? ??? ?????? ???? ??? ???? ?? "???"?? ???. ?? ?? ??? ???, ? ??, ?? ?? ??? ??? ? ????. ????. ???? ???? ?? JavaScript ??? ??? ??? ? ????.
??? ???
JavaScript? ? ????? ?? ???? ?? ?? ??? ??? ??? ??? ???? ????? ??? ? ?? ????? JavaScript? ???? ? ???? ??? ? ????. .
HTML ??? ?? ??
<html> <head> <script> alert('Hello, world'); </script> </head> <body> <p>...</p> </body> </html>
???? ?? ??
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php.cn</title> </head> <body> <button type="button" onclick="alert('你好!')">點(diǎn)我!</button> </body> </html>
HTML ??? ??
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <p id="demo"> 內(nèi)容。 </p> <script> function myFunction() { x=document.getElementById("demo"); // 找到元素 x.innerHTML="Hello JavaScript!"; // 改變內(nèi)容 } </script> <button type="button" onclick="myFunction()">點(diǎn)擊這里</button> </body> </html>
HTML ??? ??
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <script> function changeImage() { element=document.getElementById('myimage') if (element.src.match("bulbon")) { element.src="/images/pic_bulboff.gif"; } else { element.src="/images/pic_bulbon.gif"; } } </script> <img id="myimage" onclick="changeImage()" src="/images/pic_bulboff.gif" width="100" height="180"> <p>點(diǎn)擊燈泡查看效果</p> </body> </html>
HTML ??? ??
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> </head> <body> <p id="demo"> 改變 HTML 的樣式。 </p> <script> function myFunction() { x=document.getElementById("demo") // 找到元素 x.style.color="blue"; // 改變樣式 } </script> <button type="button" onclick="myFunction()">點(diǎn)擊這里</button> </body> </html>
?? ??
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文網(wǎng)(php.cn)</title> <script type="text/javascript"> function validate_email(field,alerttxt) { with (field) { apos=value.indexOf("@") dotpos=value.lastIndexOf(".") if (apos<1||dotpos-apos<2) {alert(alerttxt);return false} else {return true} } } function validate_form(thisform) { with (thisform) { if (validate_email(email,"Not a valid e-mail address!")==false) {email.focus();return false} } } </script> </head> <body> <form action="submitpage.htm"onsubmit="return validate_form(this);" method="post"> Email: <input type="text" name="email" size="30"> <input type="submit" value="Submit"> </form> </body> </html>