Javascript Tutorial

Please check this website: http://www.w3schools.com/JS.

1. How to Handle Simple Browsers
Browsers that do not support JavaScript, will display JavaScript as page content.
To prevent them from doing this, and as a part of the JavaScript standard, the HTML comment tag should be used to "hide" the JavaScript.
Just add an HTML comment tag <!-- before the first JavaScript statement, and a --> (end of comment) after the last JavaScript statement, like this:
<html>
<body>
<script type="text/javascript">
<!--
document.write("Hello World!");
//-->
</script>
</body>
</html>

2. Where to Put the JavaScript
JavaScripts in the body section will be executed WHILE the page loads.
JavaScripts in the head section will be executed when CALLED.

3. JavaScript Popup Boxes
Alert Box: alert("sometext");
Confirm Box: confirm("sometext");
Prompt Box: prompt("sometext","defaultvalue");
<html>
<head>
<script type="text/javascript">
function show_prompt()
{
var name=prompt("Please enter your name","Harry Potter");
if (name!=null && name!="")
{
document.write("Hello " + name + "! How are you today?");
}
}
</script>
</head>
<body>
<input type="button" οnclick="show_prompt()" value="Show prompt box" />
</body>
</html>

4. JavaScript For...In Statement
The for...in statement loops through the elements of an array or through the properties of an object.
for (variable in object)
{
code to be executed
}

5. JavaScript Events
Events are actions that can be detected by JavaScript.
(1) onLoad and onUnload

To be continued.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值