make ads load after the page is done loading

igames

New Member
Messages
34
Reaction score
0
Points
0
hey i was searching online and couldn't get a correct code for making ads load last with javascript, so i hope you can tell me how to do it and the code for it. i would be very grateful if you could give me a solution. thanks!
 

igames

New Member
Messages
34
Reaction score
0
Points
0
im sorry if im making this more difficult than it really is but im not getting the result. ok so my code for where the ad should be placed is
Code:
<span="x10ads">
<script type="text/javascript" src="http://x10hosting.com/adserve.js?corporate" width="468" height="60" id="x10ads" "></script><br>
</span>
and the ending code is
Code:
<script language="javascript">
document.getElementById("x10ads").innerHTML = "<script type="text/javascript" src="http://x10hosting.com/adserve.js?corporate" width="468" height="60" id="x10ads" "></script>";
</script>
thanks once again
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
change this
HTML:
<span="x10ads">
<script type="text/javascript" src="http://x10hosting.com/adserve.js?corporate" width="468" height="60" id="x10ads" "></script><br>
</span>
to
HTML:
<span="x10ads"></span>

the second block with the javascript innerHTML() will add the contents of that string to the block that has the id `x10ads`.
 

igames

New Member
Messages
34
Reaction score
0
Points
0
hmmmm im still not getting the result. i am not getting any ad to load so here is the code is anything wrong with it?

Code:
<span="x10ads"></span>
and
Code:
<script language="javascript">
document.getElementById("x10ads").innerHTML = " <script type="text/javascript" src="http://x10hosting.com/adserve.js?corporate" width="468" height="60" ">";
</script>
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
hmmmm im still not getting the result. i am not getting any ad to load so here is the code is anything wrong with it?[/code]
lol, i must have over looked this:

change
Code:
<span="x10ads"></span>
to
Code:
<span id="x10ads"></span>
 

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
Here's a thing I lately found out: Javascript won't execute if just entered into .innerHTML (at least for modern browsers). Here's a work around:

HTML:
<div id="x10ads"></div>
<!-- Feel free to change the tag -->

<!-- Then at bottom of page: -->
<script type="text/javascript">
var scriptEl = document.createElement('script')
scriptEl.type = 'text/javascript'
scriptEl.src = 'http://x10hosting.com/adserve.js?corporate'
document.getElementById('x10ads').appendChild(scriptEl)
</script>
Also, why did you give width and height to script tag? It's not like it's gonna do something that way..
 

igames

New Member
Messages
34
Reaction score
0
Points
0
umm im having a problem, when everything is done loading the ad loads in the rest of the page dissapears soi just want it to load where the div tags are. thanks
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
If you're gonna be doing it in this pseudo-onload way(with the ads being at the bottom of the page, rather than having them created with the onload event), then you could try placing them in an invisible div at the bottom and use the onload event to just move them. Something like:

In the <head> tag:
HTML:
<script type="text/javascript" language="Javascript">
function moveAds() {
    document.getElementById('ads').innerHTML = document.getElementById('hiddenads').innerHTML;
}
</script>
The <body> tag:
HTML:
<body onload="moveAds();">
Then where you want the ads to show up:
HTML:
<div id="ads"></div>
And this at the bottom of the page:
HTML:
<div id="hiddenads" style="display: none;">
<script type="text/javascript" src="http://x10hosting.com/adserve.js?corporate" width="468" height="60" id="x10ads"></script>
</div>
I'm not 100% sure this will work without any problem. Personally, I would generate the ads in the onload event so as to be sure the content is fully loaded first. This would be harder to do, though.
 

igames

New Member
Messages
34
Reaction score
0
Points
0
ok woiwky your code worked the best but i cant get it to diplay in the header, i dont know whats happening its allways diplaying it after the header, i tried moving it but there wasnt anything there to display it. thanks
 

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
No wonder, you didn't follow full instructions (checking the site atm)
HTML:
</head>
<script type=”text/javascript”>
Function ad()
{
document.write(<script type='text/javascript' src='http://x10hosting.com/adserve.js?corporate' ></script>
}
</script>
<center>
<center>
<body bgcolor="#1E90FF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
Not only is this invalid in any html language, it's broken
(Can't help atm, kinda busy)
 

igames

New Member
Messages
34
Reaction score
0
Points
0
ok i was trying some other things at that time, but you can look now but its loading the ad only not the page w/ the ad
Edit:
hey i am now offering 100-200 credits for whoever gets this working for me just for a bonas thanks
 
Last edited:

t2t2t

New Member
Messages
690
Reaction score
0
Points
0
ok i was trying some other things at that time, but you can look now but its loading the ad only not the page w/ the ad
Edit:
hey i am now offering 100-200 credits for whoever gets this working for me just for a bonas thanks
ss20090128210457dc0.png

Currently it stops the <script> part at about ........................................................................... here
Sorry to all who had their pages stretched.
 

igames

New Member
Messages
34
Reaction score
0
Points
0
hey im sorry i dont know why i didnt think of this earlier, but i found this code and it would load the ad later, but above the table the code to start loading the ad was in, so i moved the code that starts the loading and it worked perfectly, thanks for all your help

- Roshie
 
Top