js判断页面是否加载完毕

用 document.readyState == "complete" 判断页面是否加载完成。
document.onreadystatechange = function(){  
        if(document.readyState=="complete")  
        {  
        alert('加载完毕');
        }
}
Js代码 复制代码  收藏代码
  1. var leftDocument=window.parent.frames("leftFrame").document;   
  2.                 if(leftDocument.readyState == 'loaded' || leftDocument.readyState == 'complete')    
  3.                 {   
  4.                     leftDocument.getElementById("notes").style.display = 'block';   
  5.                     leftDocument.getElementById("others").style.display = 'none';   
  6.                 }  
 

Js代码 复制代码  收藏代码
  1. <script language="javascript">   
  2.   
  3. if (document.readyState=="complete")   
  4. {   
  5.         AdjustImageSize();   
  6. }   
  7. else  
  8. {   
  9.         document.onreadystatechange = function()   
  10.         {   
  11.               
  12.                 if (document.readyState == "complete")   
  13.                 {   
  14.                         AdjustImageSize();   
  15.                 }   
  16.         }   
  17. }   
  18.   
  19. function AdjustImageSize()   
  20. {   
  21.         var imageWidth = document.all["SendPic"].width;   
  22.         var imageHeight = document.all["SendPic"].height;   
  23.            
  24.         if (imageWidth == 0 && imageHeight == 0)   
  25.         {   
  26.                 document.write ("图片下载失败,请刷新!");   
  27.                 return;   
  28.         }   
  29.            
  30.         if (imageWidth > 160 || imageHeight > 160)   
  31.         {   
  32.                 if (imageWidth > imageHeight)   
  33.                 {   
  34.                         k = 160 / imageWidth;   
  35.                         imageHeight = imageHeight * k;   
  36.                         imageWidth = 160;   
  37.                 }   
  38.                 else  
  39.                 {   
  40.                         k = 160 / imageHeight;   
  41.                         imageWidth = imageWidth * k;   
  42.                         imageHeight = 160;   
  43.                 }   
  44.                    
  45.                 document.all["ImgResized"].value = "1";   
  46.         }   
  47.            
  48.         document.all["SendPic"].width = imageWidth;   
  49.         document.all["SendPic"].height = imageHeight;   
  50.            
  51.         document.all["ImgWidth"].value = imageWidth;   
  52.         document.all["ImgHeight"].value = imageHeight;   
  53. }   
  54. </script>  
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值