测试在网页上<script>在各个地方的执行顺序.

<!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>
<title>无标题页</title>
<script type = "text/javascript">
alert(
"head部分的script");
</script>
</head>
<script type = "text/javascript">
alert(
"body与head之间的script");

</script>
<body onload = "alert('body的onload上的script')">
<script type = "text/javascript">
alert(
"body内的script");
</script>
</body>
<script type = "text/javascript">
alert(
"body下的script");
</script>
</html>

  以上执行顺序结果是:head->body&head之间->body内->body外->body的onload ..

posted @ 2011-09-02 11:44  jayccc  阅读(165)  评论(0编辑  收藏  举报