轉自:http://www.cnblogs.com/lhb25/archive/2009/07/30/1535420.html
傳回XML 檔案資料的目前狀況。
基本文法
intState = xmlDocument.readyState;
說 明
這個屬性是唯讀,傳回值有以下的可能:
0-UNINITIALIZED:XML 對象被產生,但沒有任何檔案被載入。
1-LOADING:載入程式進行中,但檔案尚未開始解析。
2-LOADED:部分的檔案已經載入且進行解析,但物件模型尚未生效。
3-INTERACTIVE:僅對已載入的部分檔案有效,在此情況下,物件模型是有效但唯讀。
4-COMPLETED:檔案已完全載入,代表載入成功。
範 例
alert("The readyState property is " + xmlDoc.readyState); 根據頁面載入是否結束來控製圖片大小
<script language="javascript">
if (document.readyState=="complete")
{
AdjustImageSize();
}
else
{
document.onreadystatechange = function()
{
if (document.readyState == "complete")
{
AdjustImageSize();
}
}
}
function AdjustImageSize()
{
var imageWidth = document.all["SendPic"].width;
var imageHeight = document.all["SendPic"].height;
if (imageWidth == 0 && imageHeight == 0)
{
document.write ("圖片下載失敗,請重新整理!");
return;
}
if (imageWidth > 160 || imageHeight > 160)
{
if (imageWidth > imageHeight)
{
k = 160 / imageWidth;
imageHeight = imageHeight * k;
imageWidth = 160;
}
else
{
k = 160 / imageHeight;
imageWidth = imageWidth * k;
imageHeight = 160;
}
document.all["ImgResized"].value = "1";
}
document.all["SendPic"].width = imageWidth;
document.all["SendPic"].height = imageHeight;
document.all["ImgWidth"].value = imageWidth;
document.all["ImgHeight"].value = imageHeight;
}
</script>