Click to See Complete Forum and Search --> : How to execute javascript after all page is shown if you cannot use defer nor onload?


marcin_p
12-14-2002, 05:57 AM
Exacly:
How to delay executing of javascript if you cannot use
defer nor body onload due to output overwrites content of
page :(

Example:
I have to show flash baner from outside adsever:

<SCRIPT LANGUAGE="JavaScript">
document.write('<SCR'+'IPT LANGUAGE="JavaScript"
SRC="http://adserver/path/script?parameters"; ><\/SCR'+'IPT>');
</SCRIPT>

but browser waits until this script is downloaded to
execute it. The page is stoped in half of lenght. User must
wait to see rest of page.

I want browser to download and execute javascript only
after all page is shown.

defer="defer" - doesn't work because it clears page and
draws only baner code

body onload - the same as above

What to do?

Martin

Charles
12-14-2002, 06:50 AM
I think that your best bet is going to be to load the thing in an IFRAME once the page has loaded. You will have to create a page in HTML with nothing but the ad and you will want to write the IFRAME element with JavaScript so that JavaScript free people won't have to see an empty IFRAME. Something like:

<script="text/javascript">
<!--
document.write('<iframe src="" height="100" width=400" name="ad"></iframe>');
window.onload = function () {document.frames.ad.location = 'ad.html'};
// -->
</script>

marcin_p
12-14-2002, 07:46 AM
You're right but I can not use IFRAME.

Adverts have different sizes and they are different type: for example expanding flash, big semi-transparent layer. If they are executed from IFRAME they are active (visible) only in IFRAME :(

Martin

swon
12-14-2002, 08:20 AM
Hi Martin,

I think the best way to do this, is to make an upstream site, set a invisible layer with your flash- banner inside. Then use the refresh-meta to go to next side an your banner is loaded.

Or secondary use a timer in jscript onload and load the banner after your timer settings.

regards

swon