+ Reply to Thread
Results 1 to 8 of 8

Thread: Load Object Last (using JS)

  1. #1
    Community Advocate diabolo is on a distinguished road diabolo's Avatar
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,551

    Load Object Last (using JS)

    If you have a website that has ads that just take to long to load, and prevents the user from seeing your website as quickly, then you're in the right topic! I'll show you how to load any object you want, in relation to other objects.
    First, we got to understand that a browser reads the HTML from top to bottom, so if you have a script for the ad on the top of your page, the browser is going to have to finish reading that, then it goes onto the rest of the content.
    What we are going to be doing here is placing the code at the bottom, and refering back to a <span> at the top of the page..so now onto the tutorial

    Code:
    <html>
    <body>
    <span>Some ad here</span>
    Main Content
    </body>
    </html>
    as you can see I have a very, very basic webpage...(I don't even think it qualifies, but it works for what we are doing)

    Code:
    <html>
    <body>
    <span="ad"></span>
    Main Content
    <script language="javascript">
    document.getElementById("somethingloadlast").innerHTML = "Some Ad Here";
    </script>
    </body>
    </html>
    as you can see, I have gave the <span> and id, and refered to it at a script on the bottom of the page, after all the main content is loaded.


    This will load the ad after 'Main Content' has been loaded.
    Last edited by diabolo; 01-14-2008 at 02:56 PM.
    please add to my reputation if you found my post helpful, it gets me closer to free stuff. ;)

    Check out my Tutorials
    [JS] Load Object Last | [php][GD] Creating A Dynamic Signature

  2. #2
    Lord Of The Keys Synkc is an unknown quantity at this point Synkc's Avatar
    Join Date
    Jun 2007
    Location
    Hervey Bay, Australia
    Posts
    1,765

    Re: Load Object Last (using JS)

    Interesting tutorial; I don't usually work with JavaScript, but this could be useful for me, thanks.
    E-mail: synkc[at]x10hosting[dot]com
    Hirokima.com

  3. #3
    x10 Elder bigjoe4 is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    907

    Re: Load Object Last (using JS)

    That's well usefull thanks
    Last edited by bigjoe4; 01-23-2008 at 10:46 AM.
    Please visit my site: Circuit designer

  4. #4
    Community Advocate diabolo is on a distinguished road diabolo's Avatar
    Join Date
    Nov 2007
    Location
    Jersey Shore
    Posts
    1,551

    Re: Load Object Last (using JS)

    glad I could help
    please add to my reputation if you found my post helpful, it gets me closer to free stuff. ;)

    Check out my Tutorials
    [JS] Load Object Last | [php][GD] Creating A Dynamic Signature

  5. #5
    Lord Of The Keys Jesse is an unknown quantity at this point Jesse's Avatar
    Join Date
    Oct 2007
    Location
    PH
    Posts
    1,339

    Re: Load Object Last (using JS)

    Thanks for the tutorial.

  6. #6
    x10 Sophmore tgkprog is an unknown quantity at this point
    Join Date
    Oct 2007
    Location
    Bangalore India
    Posts
    222

    Re: Load Object Last (using JS)

    hi i think below is better - with a timer and fixed size so the page contents do not move when the ad appears
    Code:
    <html>
    <body>
    
    <!-- adding the size helps as the page does not jump when the advertisment  content is inserted -->
    <div id="somethingloadlast" style="size:absolute; height : 300; width: 100%">&nbsp;</div>
    
    <br/>
    Main Content
    <script language="javascript">
    var tmrHandle = setTimeout("startAds()", "200");//200 milliseconds after page loads
    function startAds(){
    	document.getElementById("somethingloadlast").innerHTML = "Some Ad Here with images too <br/><img src=\"i1.jpg\"> ... ";
    	//can use a iframe to - insert another page - maybe a generic page with ads for all pages - cahnge in one place
    	//document.getElementById("somethingloadlast").innerHTML = "<iframe src=\"../ads.html\" height=\"400\" width=\"100%\"></iframe>";
    }
    </script>
    </body>
    </html>
    Edit:
    also in your example you have
    Code:
    ...
    <span="ad"></span>
    ...
    document.getElementById("somethingloadlast").innerHTML = "Some Ad "....
    i think it should be
    Code:
    ...
    <span id="ad"></span>
    ...
    document.getElementById("ad").innerHTML = "Some Ad "....
    Edit:
    If you like my posts then press the blue tick on the top right corner of my post /\
    Last edited by tgkprog; 03-02-2008 at 10:52 PM. Reason: Automerged Doublepost
    http://sel2in.com/ Java - Mobile, Website applications PHP, My SQL, VB6 & VBA http://www.thehungersite.com

  7. #7
    x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    Re: Load Object Last (using JS)

    Never came up with this, it's logic :p
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

  8. #8
    Community Advocate Twinkie is an unknown quantity at this point Twinkie's Avatar
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,337

    Re: Load Object Last (using JS)

    Another way to do this to allow all content within the container is to load an add in a span/div element, with display off, and then call a JavaScript function with the onload property to change the parentNode of the ads container to an element at the top of the page. I would post source code, but I don't want to hijack diabolo's tutorial.
    ~~Twinkie~~



+ Reply to Thread

Similar Threads

  1. Images won't load on addon-domain (may need admin support)
    By IonCannon218 in forum Free Hosting
    Replies: 2
    Last Post: 12-14-2007, 07:35 PM
  2. Website doesn't load
    By salim in forum Free Hosting
    Replies: 2
    Last Post: 11-09-2007, 10:09 AM
  3. Site load extremely slow with PHP ads
    By HyDr@ in forum Free Hosting
    Replies: 2
    Last Post: 11-18-2006, 08:52 PM
  4. Sever Load!!!!!!! 10
    By Chirantha in forum Free Hosting
    Replies: 4
    Last Post: 08-15-2005, 11:13 AM
  5. vBulletin - Optimization !!!!!
    By bin_asc in forum Scripts & 3rd Party Apps
    Replies: 7
    Last Post: 08-05-2005, 04:27 AM

Posting Permissions

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