Use document. readyState = "complete" to determine whether the page has been loaded

Source: Internet
Author: User

Returns the current status of the XML file.
Basic syntax
IntState = xmlDocument. readyState;

Description

This attribute is read-only and the returned value may be:

0-UNINITIALIZED: XML objects are generated, but no files are loaded.
1-LOADING: The LOADING program is in progress, but the file has not started parsing.
2-LOADED: some files have been LOADED and parsed, but the object model has not yet taken effect.
3-INTERACTIVE: only valid for some loaded files. In this case, the object model is valid but read-only.
4-COMPLETED: the file is fully loaded, indicating that the file is successfully loaded.
 
Example
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 ("image download failed. Please Refresh! ");
Return;
}

If (imageWidth> 160 || imageHeight> 160)
{
If (imageWidth> imageHeight)
{
K = 160/imageWidth;
ImageHeight = imageHeight * k;
Image Width = 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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.