P
poecke
Recently I have troubled myself over a script which is supposed to
make the banners on my website load after the page has loaded, since
one of them is particularly slow. But of course the banner which
causes the site to become slow doesn't seem to agree with me
The original(working) script I received from the sponsor looks like
this:
<script language='JavaScript' type='text/javascript' src='http://
ads2.bom-media.nl/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random =
phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/
javascript' src='");
document.write ("http://ads2.bom-media.nl/adjs.php?n=" +
phpAds_random);
document.write ("&what=zone:67");
document.write ("&exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script>
<noscript>
<a href='http://ads2.bom-media.nl/adclick.php?n=adbb5903'
target='_blank'><img src='http://ads2.bom-media.nl/adview.php?
what=zone:67&n=adbb5903' border='0' alt=''></a>
</noscript>
Since JS doesn't like inserting scripts into innerHTML, I tried dozens
of things, and ended up with something which works with about every
other script except the one my sponsor gave me, namely:
<script type="text/javascript">
function setInnerHTMLAndExecScript (element, html) {
var newElement = element.cloneNode(false);
newElement.innerHTML = html;
element.parentNode.replaceChild(newElement, element);
}
</script>
<script type="text/javascript">
function doTest () {
html = [
' <script language=\'JavaScript\' type=\'text/javascript\' src=
\'http://ads2.bom-media.nl/adx.js\'></script>',
' <script language="JavaScript" type="text/javascript">',
' <!--',
' if (!document.phpAds_used) document.phpAds_used = ",";',
' phpAds_random = new String (Math.random()); phpAds_random =',
' phpAds_random.substring(2,11);',
' document.write ("<" + "script language=\'JavaScript\' type=
\'text/javascript\' src=\'");',
' document.write ("http://ads2.bom-media.nl/adjs.php?n=" +
phpAds_random);',
' document.write ("&what=zone:67");',
' document.write ("&exclude=" + document.phpAds_used);',
' if (document.referrer)',
' document.write ("&referer=" + escape(document.referrer));',
' document.write ("\'><" + "/script>");',
' //-->',
' <\/script>',
' <noscript>',
' <a href=\'http://ads2.bom-media.nl/adclick.php?n=adbb5903\'
target=\'_blank\'><img src=\'http://ads2.bom-media.nl/adview.php?
what=zone:67&n=adbb5903\' border=\'0\' alt=\'\' ><\/a>',
' <\/noscript> '
].join('\r\n');
setInnerHTMLAndExecScript(document.getElementById('banner_midden'),
html);
}
window.onload = doTest;
</script>
(yes, I did borrow that example from someone on this usegroup)
It works, but, it doesn't load 'inside' the div container, but rather
just loads the banner in a blank page(and doesn't end loading, for
some reason).
Please help me. I've spent hours on this bugger... I'd at least like
to see my efforts not be in vain..
Thanks a bunch,
Poecke
make the banners on my website load after the page has loaded, since
one of them is particularly slow. But of course the banner which
causes the site to become slow doesn't seem to agree with me
The original(working) script I received from the sponsor looks like
this:
<script language='JavaScript' type='text/javascript' src='http://
ads2.bom-media.nl/adx.js'></script>
<script language='JavaScript' type='text/javascript'>
<!--
if (!document.phpAds_used) document.phpAds_used = ',';
phpAds_random = new String (Math.random()); phpAds_random =
phpAds_random.substring(2,11);
document.write ("<" + "script language='JavaScript' type='text/
javascript' src='");
document.write ("http://ads2.bom-media.nl/adjs.php?n=" +
phpAds_random);
document.write ("&what=zone:67");
document.write ("&exclude=" + document.phpAds_used);
if (document.referrer)
document.write ("&referer=" + escape(document.referrer));
document.write ("'><" + "/script>");
//-->
</script>
<noscript>
<a href='http://ads2.bom-media.nl/adclick.php?n=adbb5903'
target='_blank'><img src='http://ads2.bom-media.nl/adview.php?
what=zone:67&n=adbb5903' border='0' alt=''></a>
</noscript>
Since JS doesn't like inserting scripts into innerHTML, I tried dozens
of things, and ended up with something which works with about every
other script except the one my sponsor gave me, namely:
<script type="text/javascript">
function setInnerHTMLAndExecScript (element, html) {
var newElement = element.cloneNode(false);
newElement.innerHTML = html;
element.parentNode.replaceChild(newElement, element);
}
</script>
<script type="text/javascript">
function doTest () {
html = [
' <script language=\'JavaScript\' type=\'text/javascript\' src=
\'http://ads2.bom-media.nl/adx.js\'></script>',
' <script language="JavaScript" type="text/javascript">',
' <!--',
' if (!document.phpAds_used) document.phpAds_used = ",";',
' phpAds_random = new String (Math.random()); phpAds_random =',
' phpAds_random.substring(2,11);',
' document.write ("<" + "script language=\'JavaScript\' type=
\'text/javascript\' src=\'");',
' document.write ("http://ads2.bom-media.nl/adjs.php?n=" +
phpAds_random);',
' document.write ("&what=zone:67");',
' document.write ("&exclude=" + document.phpAds_used);',
' if (document.referrer)',
' document.write ("&referer=" + escape(document.referrer));',
' document.write ("\'><" + "/script>");',
' //-->',
' <\/script>',
' <noscript>',
' <a href=\'http://ads2.bom-media.nl/adclick.php?n=adbb5903\'
target=\'_blank\'><img src=\'http://ads2.bom-media.nl/adview.php?
what=zone:67&n=adbb5903\' border=\'0\' alt=\'\' ><\/a>',
' <\/noscript> '
].join('\r\n');
setInnerHTMLAndExecScript(document.getElementById('banner_midden'),
html);
}
window.onload = doTest;
</script>
(yes, I did borrow that example from someone on this usegroup)
It works, but, it doesn't load 'inside' the div container, but rather
just loads the banner in a blank page(and doesn't end loading, for
some reason).
Please help me. I've spent hours on this bugger... I'd at least like
to see my efforts not be in vain..
Thanks a bunch,
Poecke