日期:2014-05-16  浏览次数:20372 次

判断frame加载过程
为什么这样写,去判断frame是否加载完成无效?我发现this.readyState 的值总是undefined,而且onreadystate事件也只触发了两次,按道理来说应该会触发三次的啊。readyState不是有三个状态吗?
我的html代码如下
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>ATS Home page</title>
<script type="text/javascript" src="resources/jquery/jquery-1.6.1.js"></script>
<script type = "text/javascript">
var oFrm = document.getElementById('content');
  oFrm.onload = oFrm.onreadystatechange = function() {
  if (this.readyState && this.readyState == 'loading') {
  alert("frame loading *********");
  }
  else if (this.readyState && this.readyState == 'complete'){
  alert("frame load complete *************");
  }

  }
</script>
</head>
<frameset rows = "65,*" border = "0">
<frame scrolling ="no" noresize = "noresize" src = "head" ></frame>
<frame scrolling ="auto" noresize = "noresize" id = "content" name = "content"src=""></frame>
</frameset>
</html>

------解决方案--------------------
this.readyState 改为oFrm.readyState试试
------解决方案--------------------
var oFrm = document.getElementById('content');
 这个ofrm都没有值。。