用 document.readyState == "complete" 判断页面是否加载完成。

传回XML 文件资料的目前状况。  
基本语法
intState = xmlDocument.readyState;
 
说 明

这个属性是只读的,传回值有以下的可能:

0-UNINITIALIZED:XML 对象被产生,但没有任何文件被加载。
1-LOADING:加载程序进行中,但文件尚未开始解析。
2-LOADED:部分的文件已经加载且进行解析,但对象模型尚未生效。
3-INTERACTIVE:仅对已加载的部分文件有效,在此情况下,对象模型是有效但只读的。
4-COMPLETED:文件已完全加载,代表加载成功。
 
 
范 例
alert("The readyState property is " + xmlDoc.readyState);


None.gif < script language = " javascript " >
None.gif
None.gif
if  (document.readyState == " complete " )
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif        AdjustImageSize();
ExpandedBlockEnd.gif}

None.gif
else
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif        document.onreadystatechange 
= function()
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif           
InBlock.gif                
if (document.readyState == "complete")
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                        AdjustImageSize();
ExpandedSubBlockEnd.gif                }

ExpandedSubBlockEnd.gif        }

ExpandedBlockEnd.gif}

None.gif
None.gif
function  AdjustImageSize()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif        
var imageWidth = document.all["SendPic"].width;
InBlock.gif        
var imageHeight = document.all["SendPic"].height;
InBlock.gif        
InBlock.gif        
if (imageWidth == 0 && imageHeight == 0)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif                document.write (
"图片下载失败,请刷新!");
InBlock.gif                
return;
ExpandedSubBlockEnd.gif        }

InBlock.gif        
InBlock.gif        
if (imageWidth > 160 || imageHeight > 160)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif                
if (imageWidth > imageHeight)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                        k 
= 160 / imageWidth;
InBlock.gif                        imageHeight 
= imageHeight * k;
InBlock.gif                        imageWidth 
= 160;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                        k 
= 160 / imageHeight;
InBlock.gif                        imageWidth 
= imageWidth * k;
InBlock.gif                        imageHeight 
= 160;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
InBlock.gif                document.all[
"ImgResized"].value = "1";
ExpandedSubBlockEnd.gif        }

InBlock.gif        
InBlock.gif        document.all[
"SendPic"].width = imageWidth;
InBlock.gif        document.all[
"SendPic"].height = imageHeight;
InBlock.gif        
InBlock.gif        document.all[
"ImgWidth"].value = imageWidth;
InBlock.gif        document.all[
"ImgHeight"].value = imageHeight;
ExpandedBlockEnd.gif}

None.gif
</ script >
None.gif
None.gif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值