zoukankan      html  css  js  c++  java
  • [转]用 document.readyState == "complete" 判断页面是否加载完成。

    本文转自:http://www.cnblogs.com/ryb/archive/2006/03/29/361510.aspx
    原文如下:
    传回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>

  • 相关阅读:
    [ERR] Node 10.211.55.8:7001 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.
    PAT A1137 Final Grading (25 分)——排序
    PAT A1136 A Delayed Palindrome (20 分)——回文,大整数
    PAT A1134 Vertex Cover (25 分)——图遍历
    PAT A1133 Splitting A Linked List (25 分)——链表
    PAT A1132 Cut Integer (20 分)——数学题
    PAT A1130 Infix Expression (25 分)——中序遍历
    PAT A1142 Maximal Clique (25 分)——图
    PAT A1141 PAT Ranking of Institutions (25 分)——排序,结构体初始化
    PAT A1140 Look-and-say Sequence (20 分)——数学题
  • 原文地址:https://www.cnblogs.com/freeliver54/p/1579567.html
Copyright © 2011-2022 走看看