2014年8月31日 星期日

Advanced JS Chapter 2

網路連線集線器、交換器、路由器、存取點關係圖
(圖片來源:http://windows.microsoft.com/zh-tw/windows/hubs-switches-routers-access-points-differ#1TC=windows-7)

JavaScript (index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Example</title>
<script type="text/javascript">
window.onload=function() {
    var a = function(b) {
        return b + 10;
    };
    console.log( a(5) );
    
    var b = function() {
        return 3;
    };
    console.log( a( b() ) );
    
    var json = {
        "name" : "QQBoxy",
        "number" : 10,
        "action" : function() {
            console.log("Hello");
        }
    };
    json.action();
    
    document.getElementById("poo").onclick = function() {
        document.getElementById("foo").innerHTML = "Hello<br />World";
    };
    document.getElementById("boo").onclick = function() {
        location.href = "http://www.google.com/";
    };
};
</script>
</head>
<body>
Text: <button id="poo">Click me</button><br />
Link: <button id="boo">Click me</button><br />
<div id="foo"></div>
</body>
</html>

加快網頁下載速度,使用壓縮器:
http://closure-compiler.appspot.com/home

保護原始碼的方法,使用混淆器:
http://utf-8.jp/public/aaencode.html

沒有留言:

張貼留言