源代码 :
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>开源教程(ossoft.cn)</title> </head> <body> <h2>JavaScript <b>this</b> 关键字</h2> <p>实例中,<b>this</b> 指向了 window 对象:</p> <p id="demo"></p> <script> "use strict"; var x = this; document.getElementById("demo").innerHTML = x; </script> </body> </html>
运行结果