Results 1 to 5 of 5

Thread: change onload to something else?

  1. #1
    Join Date
    Apr 2007
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default change onload to something else?

    Here is the code I have on my index page in the header:

    <SCRIPT language=JavaScript src="keywords.js" type=text/javascript></SCRIPT>




    The very first line of "keywords.js" is:
    window.onload = function() {

    So here is my question:

    How do I go about changing the first line of keywords.js.

    shouldn't I change window.onload to something else???

    or should I keep it the same?

    It's just that right now, my pages are loading slowly.

    Thanks in advance.

  2. #2
    Join Date
    Feb 2007
    Location
    England
    Posts
    254
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Hummm....

    I doubt that it is the Javascript making your script run slowly.

    Maybe you have lots of images on your page, or dynamically generated HTML or maybe a slow server. Check these out and report back if there is still a problem. Include the script you are using and a link to the page too (If online)

  3. #3
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    It is better if you use a layout which is purely CSS based rather than a table based page layout.

    As Bob said reduce the usage of big image/movie/music file in the web page.

  4. #4
    Join Date
    Apr 2007
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ok

    I'll work on getting rid of unnecessary files and images.

    But most of the stuff I have on my website has to be there.

    Isn't there a function that will work before the page loads?

    instead of:
    window.onload = function() {

  5. #5
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    Have a look at the following code from which you can learn the execution path of the scripts in a web page.

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    //This example shows the which programming statements or function calls exectues in a one by one fashion
    alert('Standalone alert statement; the first statement in the script tag');
    
    function callMe()
    {
    	alert('Inside the callMe function');
    }
    
    //onload event assignment.
    window.onload = function () {
    	alert('inside the onload event');
    }
    
    //Invoking the callMe function 
    callMe();
    </script>
    </head>
    
    <body>
    </body>
    </html>
    Please let me know if you have any problem with the above code.

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
  •