Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    window.onload doesn't work in IE, but works on FF

    I met a confusion about window.onload()

    in my index page, here is the code:
    <script language = "JavaScript">
    $(document).ready(function(){
    Main.loadHome();
    }
    });
    </script>

    <body>
    ......
    <div id="main"></div>
    .......
    </body>

    js file:

    Main = function()
    {}
    Main.loadHome = function()
    {
    $('#main').load("homepage.php");
    }

    homepage.php

    <script language="JavaScript" type="text/javascript">
    window.onload=function(){
    ....................
    }
    </script>

    Here is the problem
    it works in FF, but seems window.onload didn't call in IE, which makes me confused.
    Last edited by ssheng; 07-29-2010 at 10:22 AM.

  • #2
    New to the CF scene
    Join Date
    Jul 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyone help me?

  • #3
    Banned
    Join Date
    Jul 2010
    Posts
    66
    Thanks
    0
    Thanked 1 Time in 1 Post
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <title>Busted!</title>
    <meta name="author" content="Dean Edwards"/>
    <!-- keeping code tidy!! -->
    <meta name="copyright" content="&copy; copyright 2005, Dean Edwards"/>
    <style>
    #message {
    background-color: red;
    color: white;
    font-weight: bold;
    font-size: 2em;
    text-align: center;
    }
    </style>
    <script type="text/javascript">
    function init() {
    // quit if this function has already been called
    if (arguments.callee.done) return;

    // flag this function so we don't do the same thing twice
    arguments.callee.done = true;

    // create the "page loaded" message
    var text = document.createTextNode("Page loaded!");
    var message = document.getElementById("message");
    message.appendChild(text);
    };

    /* for Mozilla */
    if (document.addEventListener) {
    document.addEventListener("DOMContentLoaded", init, false);
    }

    /* for Internet Explorer */
    /*@cc_on @*/
    /*@if (@_win32)
    document.write("<script defer src=ie_onload.js><"+"/script>");
    /*@end @*/

    /* for other browsers */
    window.onload = init;
    </script>

    </head>
    <body>
    <h1>Busted!</h1>
    <p id="message"></p>
    <script type="text/javascript">
    // create a unique image source so that this page works with continued testing
    var src = "http://www.nasa.gov/images/content/84857main_EC04-0325-23_lg.jpg?" + Number(new Date);
    document.write("<img src=" + src + " height=240 width=300>");
    </script>
    </body>
    </html>

    This works fine in all the browsers
    Thanks & Regards


  •  

    Posting Permissions

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