当前位置: 首页 > 网络学院 > 客户端脚本教程 > VBScript > VBScript 放置
Head section
Scripts can be placed in the head section. Usually we put all the "functions" in the head section. The reason for this is to be sure that the script is loaded before the function is called.
脚本可以放在head区。一般我们将所有的"function"放在head区。原因在于这样可以保证脚本中的function可以在调用前先加载完毕。
Body section
Execute a script that is placed in the body section. Scripts in the body section are executed when the page is loading.
执行脚本放在body区。在body里的脚本会在页面加载的时候执行。
Scripts in a page will be executed immediately while the page loads into the browser. This is not always what we want. Sometimes we want to execute a script when a page loads, other times when a user triggers an event.
我们不总是希望当页面加载到浏览器后会立即执行页面里的脚本,一些时候我们需要用户触发一个事件时才执行脚本。
Scripts in the head section: Scripts to be executed when they are called or when an event is triggered go in the head section. When you place a script in the head section you will assure that the script is loaded before anyone uses it:
在head区中的脚本:放在head区的脚本,当它们被调用或是被某个事件触发后就会被执行。当你将脚本放在head区就可以保证这些脚本在使用前全部加载完毕:
<html> |
Scripts in the body section: Scripts to be executed when the page loads go in the body section. When you place a script in the body section it generates the content of the page:
在body区内的脚本:当页面加载时在body区内的脚本将被执行。当你将脚本放在body区时它通常会产生页面的内容
<html> |
Scripts in both the body and the head section: You can place an unlimited number of scripts in your document, so you can have scripts in both the body and the head section.
在body和head区都有脚本:文档中你可以无限制的放置脚本,因此你可以同时在body和head区里放脚本。
<html> |