Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Jul 2007
    Posts
    16
    Member #
    15531
    is there a javascript to make a browse read and load an external javascript sheet before it loads the rest of the site.

    a javascript for a javascript

    I am using a centering javascript to reposition my divs and when you load the site
    http://paysonhomeguide.com it start loading the images and style sheet first. Want to know how i could fix this

  2.  

  3. #2
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    Most likely what you need is Javascript that's loaded when the immediately when the DOM is displayed, right? Not like the usual window.onLoad that waits for everything else. The library jQuery has such a system (which does anything on HTML the moment it's loaded, without waiting for anything else), so you might want to check them out...
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  4. #3
    Junior Member
    Join Date
    Jun 2007
    Location
    Birmingham, UK
    Posts
    1
    Member #
    15448
    Why don't you just center your div using CSS?
    It would be more compatible for people who have JavaScript switched off.

  5. #4
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    That would be the preferred method, of course. But in other times you'll also want JS to be available right after the DOM is ready, and I've yet to see other functionality for this.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.

  6. #5
    Junior Member
    Join Date
    Jul 2007
    Posts
    16
    Member #
    15531
    Quote Originally Posted by Steax
    That would be the preferred method, of course. But in other times you'll also want JS to be available right after the DOM is ready, and I've yet to see other functionality for this.
    do you have to know javascript to use it or is it pretty user friendly?

  7. #6
    Senior Member Steax's Avatar
    Join Date
    Dec 2006
    Location
    Bandung, Indonesia
    Posts
    1,207
    Member #
    14572
    You'll probably dive into a new way of doing javascript, but I think its really user friendly.

    In jQuery, the $() is the magic function. Inside it you can put something like a CSS selector to pick an object, then do stuff on it (check the website). If you put:

    Code:
     $(document).ready(function(){
       // Your code here
     });
    Will allow you to run code immediately after the DOM is ready, before images and the stuff run, but after the HTML is available so you can directly manipulate it.
    Note on code: If I give code, please note that it is simply sample code to demonstrate an effect. It is not meant to be used as-is; that is the programmer's job. I am not responsible to give you support or be held liable for anything that happens when using my code.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:50 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com