Help with java - column loads last

Got a problem on gaydemon. My banner program is using a javascript which sits at the bottom of column 1 (main content). This causes the column 2 (right hand side column) to load later than the main content.

It means that for a short time you dont see any column at all, because the javascript is excecuting first before it then goes on to loading the rest of the page.

Now, how can I change so that the javascript doesnt excute until the whole page has loaded?

http://www.gaydemon.com/directory/hardcore/

If you reload it a couple of times you will see what i mean. Its not for a long time, but doesnt it look odd?

The java I use is:

<script type="text/javascript"><!--//<![CDATA[
   var m3_u = (location.protocol=='https:'?'https://www.gaydemonads.com/www/delivery/ajs.php':'http://www.gaydemonads.com/www/delivery/ajs.php');
   var m3_r = Math.floor(Math.random()*99999999999);
   if (!document.MAX_used) document.MAX_used = ',';
   document.write ("<scr"+"ipt type='text/javascript' src='"+m3_u);
   document.write ("?zoneid=2&target=_blank");
   document.write ('&cb=' + m3_r);
   if (document.MAX_used != ',') document.write ("&exclude=" + document.MAX_used);
   document.write (document.charset ? '&charset='+document.charset : (document.characterSet ? '&charset='+document.characterSet : ''));
   document.write ("&loc=" + escape(window.location));
   if (document.referrer) document.write ("&referer=" + escape(document.referrer));
   if (document.context) document.write ("&context=" + escape(document.context));
   if (document.mmm_fo) document.write ("&mmm_fo=1");
   document.write ("'><\/scr"+"ipt>");
//]]>--></script><noscript><a href="/www/delivery/avw.php?zoneid=18&n=af062b2b" target="_blank"><img src="/www/delivery/avw.php?zoneid=18&n=af062b2b" border="0" alt="click here to visit this site!" /></a></noscript>

Re: Help with java - column loads last

Are you saying that if you take out the banner ad at the end of the main column that the page loads differently? Browsers typically render the page from top to bottom of the HTML document (not the visible page). What you’re seeing could be completely normal if the main column is somewhat complex. Take out the banner ad and see if there’s a difference. I’m guessing it’ll be about the same.

Re: Help with java - column loads last

I have noticed the same thing on gaydemon.biz

There is a slight pause before the board loads.

Re: Help with java - column loads last

Try adding defer=“defer” to the first <script text="… line

Or put the script in an onload event. This will load it last.

Or use one of the other options openx gives to display the banner.

Jimmy

Re: Help with java - column loads last

Thats exactly why it loads a bit strange. THe browser reads top to bottom and because I use CSS only for layout the right hand column comes after the bottom banner.

So it reads half the page, hits the java (loads java) then continous to read the rest of the page.

Its only when I use this javascript way of calling a banner.

Re: Help with java - column loads last

I tried defer=“defer” earlier today, but the page just froze. I’m not sure if you can use defer on a javascript which isnt a seperate file.

Its the onload event Im hoping might work, but I dont know how to add or use it. Any ideas how I can add a onload to the above javascript?

[quote=Nicedreams;23903]Try adding defer=“defer” to the first <script text="… line

Or put the script in an onload event. This will load it last.

Or use one of the other options openx gives to display the banner.

Jimmy[/quote]

Re: Help with java - column loads last

It all loads very fast for me. If I was your typical surfer, I would never notice anything strange.

Re: Help with java - column loads last

[QUOTE=gaydemon;23940]Thats exactly why it loads a bit strange. THe browser reads top to bottom and because I use CSS only for layout the right hand column comes after the bottom banner.

So it reads half the page, hits the java (loads java) then continous to read the rest of the page.

Its only when I use this javascript way of calling a banner.[/QUOTE]

If it bothers you (not sure how big of a problem this really is) - I’d suggest putting the Javascript at the bottom of the page and having it rewrite the contents of a blank <div> you’ve declared previously at the original location. You’d be doing something similar to what SWFObject does in terms of rewriting the div.

Re: Help with java - column loads last

[QUOTE=gaydemon;23941]I tried defer=“defer” earlier today, but the page just froze. I’m not sure if you can use defer on a javascript which isnt a seperate file.

Its the onload event Im hoping might work, but I dont know how to add or use it. Any ideas how I can add a onload to the above javascript?[/QUOTE]

Oops. Yeah, the defer is for external files.

You would need to put the script into a function in the header. And call it in a div element. Search for putting javascript into div elements.

Here is an example that might help: http://blog.paranoidferret.com/index.php/2007/09/27/html-and-javascript-putting-it-all-together/

Jimmy

Re: Help with java - column loads last

Thanks to you both, I think thats what I am trying to figure out. Someone else suggested doing it by CSS Positioning but that can just go so very wrong and gets messy.

I’ll look that up then. THanks!

[quote=Nicedreams;23948]Oops. Yeah, the defer is for external files.

You would need to put the script into a function in the header. And call it in a div element. Search for putting javascript into div elements.

Here is an example that might help: http://blog.paranoidferret.com/index.php/2007/09/27/html-and-javascript-putting-it-all-together/

Jimmy[/quote]

Re: Help with java - column loads last

Its not too bad… but im pretty anal… :wink:

Re: Help with java - column loads last

well its taken me 2 days… :bang:

I tested and tried every bloody solution to serving banners for OpenX.

In the end, Ive had to use Iframes. Even if i dont like em…

But its proved to be the only solution which does not slow down the loading time of the page.

Anyway just for future reference. Unless you have Openx installed on the same server as where you are serving the banners, there is no way of not getting a delay. Only solution for now is Iframes.