实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<p>全局函数 myFunction() 会自动成为 window 对象的方法。</p>
6
7
<p>myFunction() is the same as window.myFunction().</p>
8
9
<p id="demo"></p>
10
11
<script>
12
function myFunction(a, b) {
13
    return a * b;
14
}
15
document.getElementById("demo").innerHTML = window.myFunction(10, 2); 
16
</script>
17
18
</body>
19
</html>
20