Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 3.00 average.
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-15-2004, 04:08 PM   PM User | #1
tomzl
New to the CF scene

 
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tomzl is an unknown quantity at this point
A banner javascript slows down my site - suggestions?

I have a script for rotating banners on my page. A company sells banners on pages that join their advertising system. I put their code on my page and now it is slowing it down because the whole page waits for the banner to load before it shows the rest of the contents of my page.

I am a complete newbie when it comes to scripts but I remember seeing a script for roll over images that preloaded all the images so that when someone went over the pic with their mouse, a roll over image immediately appeared.

This made me think that if there is a preload function, there must also be a postload? function. A function that tells the script to only start working after the rest of the page has been shown.

I'm sure this sounds stupid but I don't know any other way to describe it. Any help or advice where to look for a solution to this problem would be greatly appreciated.
tomzl is offline   Reply With Quote
Old 09-15-2004, 04:45 PM   PM User | #2
NanakiXIII
Regular Coder

 
Join Date: Dec 2003
Posts: 100
Thanks: 1
Thanked 0 Times in 0 Posts
NanakiXIII is an unknown quantity at this point
Use an onLoad event in your body tags to call the javascript.
NanakiXIII is offline   Reply With Quote
Old 09-15-2004, 05:49 PM   PM User | #3
tomzl
New to the CF scene

 
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tomzl is an unknown quantity at this point
This is the part that I have to paste in my html in order for the banner to work.

<!-- ZACETEK CENTRALIPROM.COM OGLASI -- © 2000-2003 IPROM d.o.o, Ljubljana -->
<SCRIPT LANGUAGE="javascript1.1" SRC="http://ads.centraliprom.com/central.bin/adimpr?i=ohksa3wj&k=1&s=468x60"></SCRIPT><NOSCRIPT><a href="http://ads.centraliprom.com/central.bin/adclick?i=ohksa3wj&k=1&s=468x60"><img src="http://ads.centraliprom.com/central.bin/adimpress?i=ohksa3wj&k=1&s=468x60" width="468" height="60"></a></NOSCRIPT>
<!-- KONEC CENTRALIPROM.COM OGLASI -- © 2000-2003 IPROM d.o.o, Ljubljana -->



Could you tell me how exactly to write the onLoad event into the body tag?

<body onLoad ...?>
tomzl is offline   Reply With Quote
Old 09-15-2004, 07:18 PM   PM User | #4
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
You must have a tables based web page, that makes it easy for advertisers to ensure your page won't display until their advertisement is ready for display with the page. If you want to fix this without performing major surgery on your web page the best thing you can do is to adjust your web page so the code for the advertisement is totally outside any <table></table> tags.

I would also contact the advertiser and demand they upgrade their servers or their link to the web, being slow is not excusable. You might want to double-check whatever contract you have with them to see if there are any "performance" clauses you can directly demand they live up to.
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 09-15-2004, 07:21 PM   PM User | #5
NanakiXIII
Regular Coder

 
Join Date: Dec 2003
Posts: 100
Thanks: 1
Thanked 0 Times in 0 Posts
NanakiXIII is an unknown quantity at this point
I'm not sure how to call external scripts onLoad, plainly onLoad="url" might work, but I've never tried. Maybe someone else might help you with it.

But try Roy Sinclair's first. It'll probably work.
NanakiXIII is offline   Reply With Quote
Old 09-15-2004, 07:55 PM   PM User | #6
tomzl
New to the CF scene

 
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tomzl is an unknown quantity at this point
My first action was to e-mail them and ask them why their script slows down my page. They didn't reply so I was forced to find an answer elsewhere.

Roy, I tried putting the banner outside any tables and it did help with loading my page better. Thanks a lot. However, I would still like to find a better solution which would allow me to put banners into tables as well since I would like to put them on my forum which gets most of the traffic. Anyone have an idea how to do this?
tomzl is offline   Reply With Quote
Old 09-15-2004, 08:00 PM   PM User | #7
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
One dirty little secret about tables is that the browser has difficulty deciding how wide cells have to be and how tall they have to be until it has the full content of the cell available. The newer browsers try their best to render as much of the page as they can and will go back and readjust the page to fit if they have to but there are simple techniques to ensure that the content of the table isn't rendered until it's all available and when the table is pretty much your whole page (ie a table based layout) then just one element not yet received can hold up the rendering of the whole page (which is what you're experiencing). Advertisers are very aware of that and will make sure their content falls into that category because they want to make sure that a sufer hitting a page with their ad on it doesn't find a link to the next page until they've seen the ad.
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 09-15-2004, 09:55 PM   PM User | #8
jamescover
Regular Coder

 
Join Date: Aug 2002
Location: USA
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
jamescover is an unknown quantity at this point
One way:

create an iframe in your main page:

<iframe name="adFrame" src="" width="475" height="75" align="center" frameborder="0"></iframe>

Ad this to the <body> tag of your main page:

<body onload="javascript:window.adFrame.location.href='adScript.html'";>

Put the ad script in a page named adScript.html


-james
__________________
"God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "
jamescover is offline   Reply With Quote
Old 09-15-2004, 10:34 PM   PM User | #9
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
Theoriticaly, this should work:

Code:
<body onload="loadBanner()">


Load Banner wherever script is placed:
<!-- ZACETEK CENTRALIPROM.COM OGLASI -- © 2000-2003 IPROM d.o.o, Ljubljana -->
<script type="text/javascript" id="banner">
  function loadBanner(){ 
   var banner = document.getElementById('banner');
   var script = document.createElement('script');
       script.type = 'text/javascript';
       script.src = 'http://ads.centraliprom.com/central.bin/adimpr?i=ohksa3wj&k=1&s=468x60';
       banner.parentNode.insertBefore(script,banner.nextSibling);
  }
</script>
<NOSCRIPT>
<a href="http://ads.centraliprom.com/central.bin/adclick?i=ohksa3wj&k=1&s=468x60">
<img src="http://ads.centraliprom.com/central.bin/adimpress?i=ohksa3wj&k=1&s=468x60" width="468" height="60"></a>
</NOSCRIPT>
<!-- KONEC CENTRALIPROM.COM OGLASI -- © 2000-2003 IPROM d.o.o, Ljubljana -->
.....Willy
Willy Duitt is offline   Reply With Quote
Old 09-16-2004, 12:30 AM   PM User | #10
tomzl
New to the CF scene

 
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tomzl is an unknown quantity at this point
Jamescover's idea works great, I haven't tried the other one yet. The only problem remains if the banner is a resizable one that folds down when you go over with your mouse but I can live with that. You guys are great, thank you for all the help and in such a short time period.

Last edited by tomzl; 09-16-2004 at 12:58 AM..
tomzl is offline   Reply With Quote
Old 09-16-2004, 05:29 AM   PM User | #11
jamescover
Regular Coder

 
Join Date: Aug 2002
Location: USA
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
jamescover is an unknown quantity at this point
Ummm, I hope you changed this typo:


<body onload="javascript:window.adFrame.location.href='adScript.html'";>


to this:


<body onload="javascript:window.adFrame.location.href='adScript.html';">


-james
__________________
"God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "
jamescover is offline   Reply With Quote
Old 10-05-2004, 06:32 PM   PM User | #12
tomzl
New to the CF scene

 
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tomzl is an unknown quantity at this point
I tried all the suggested ideas and the one with the iframe worked best. However, there is a problem when I try to put two iframes in one page (header and footer). For an unknown reason, only one loads up with the script while the other one remains empty. Is there a way to put two iframes in one page so that both work?
tomzl is offline   Reply With Quote
Old 10-05-2004, 10:19 PM   PM User | #13
Willy Duitt
Banned

 
Join Date: Sep 2003
Posts: 3,620
Thanks: 0
Thanked 0 Times in 0 Posts
Willy Duitt is an unknown quantity at this point
You would need to use unique iframe names... not the same one...

.....Willy
Willy Duitt is offline   Reply With Quote
Old 10-08-2004, 02:27 PM   PM User | #14
tomzl
New to the CF scene

 
Join Date: Sep 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
tomzl is an unknown quantity at this point
So this should work?

<body onload="javascript:window.adFrame1.location.href='adScript.html';" onload="javascript:window.adFrame2.location.href='adScript.html';">


and this for the first banner

<iframe name="adFrame1" src="" width="475" height="75" align="center" frameborder="0"></iframe>

and this for the second banner ?

<iframe name="adFrame2" src="" width="475" height="75" align="center" frameborder="0"></iframe>
tomzl is offline   Reply With Quote
Old 10-08-2004, 10:44 PM   PM User | #15
hemebond
Senior Coder

 
Join Date: Jul 2004
Location: New Zealand
Posts: 1,315
Thanks: 0
Thanked 2 Times in 2 Posts
hemebond is an unknown quantity at this point
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
	<head>
		<title>44698</title>
	</head>
	<body>
		<a id="advert" href="http://ads.centraliprom.com/central.bin/adclick?i=ohksa3wj&k=1&s=468x60">
			<noscript>
				<img src="htp://ads.centraliprom.com/central.bin/adimpress?i=ohksa3wj&k=1&s=468x60">
			</noscript>
		</a>
	</body>
	<script type="text/javascript">
		var image = document.createElement('img');
		image.setAttribute('src','htp://ads.centraliprom.com/central.bin/adimpress?i=ohksa3wj&k=1&s=468x60');
		document.getElementById('advert').appendChild(image);
	</script>
</html>
hemebond is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:28 AM.


Advertisement
Log in to turn off these ads.