Advanced Search

Results 1 to 2 of 2

Thread: Displaying and refreshing a message while JavaScript code is executing

  1. #1
    Join Date
    Aug 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Displaying and refreshing a message while JavaScript code is executing

    I have javaScript code that runs at onload event of the html page. This JavaScript code take few seconds to finnish. I would like to display message to my user such as 'Please wait while page is build' and hide this message once the JavaScript code runs complete.

    How can i acheive that. Thanks for your help.

    M. Uppal

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    A nice effect is to put the rest of the page in "shadow":
    Code:
    var b = document.createElement("div"),
      c = document.createElement("div");
    c.style.position = b.style.position = "absolute";
    c.style.top = c.style.left = "0";
    c.style.height = c.style.width = "100%";
    c.style.backgroundColor = "black";
    c.style.filter = "alpha(Opacity=" + Math.floor((c.style.opacity = c.style.MozOpacity = c.style.KhtmlOpacity = "0.5") * 100) + ")";
    b.style.top = b.style.left = "45%";
    b.style.fontSize = "300%";
    b.style.border = "2px solid red";
    b.style.backgroundColor = "white";
    b.appendChild(document.createTextNode("Please be patient while the document is loading."));
    document.body.appendChild(c);
    document.body.appendChild(b);
    
    // long slow code goes here
    
    document.body.removeChild(c);
    document.body.removeChild(b);
    c = b = null;
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •