Forum Moderators: open

Message Too Old, No Replies

i need help to delay the loading of part of the page

         

abdosaad

2:03 pm on May 1, 2009 (gmt 0)

10+ Year Member



for example
this is the page
<snip>

i need to delay the appearance on the first add <blue one >

for like 8 or 9 seconds

** if you wait in the page for 15 second you will see that the download link will appear so i want to delay the add before it for 8 second by the same way

i really need your help , thank you any way

this is the code


<script type="text/javascript">
<!--
function fc() {
if(c>0){
document.getElementById("dl").innerHTML = ' ';
c=c-1;
setTimeout("fc()", 1000);
} else {
var tt = '<h3 style="font-size:12pt;"><a href="<?php echo $baseurl . "/n.php?u=" . $i; ?>">click here to continue</a></h3>';
document.getElementById("dl").innerHTML = tt;
}
}
var c=15;
if (window.location.hash == "#dlt")
c = 0;
//-->
</script>

<script type="text/javascript">
<!--
fc();
//-->
</script>

whoisgregg

3:53 pm on May 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, abdosaad!

The code you've provided seems like it should work fine. Perhaps you could try to describe again what you are trying to accomplish and how the current script isn't working?

abdosaad

11:49 pm on May 4, 2009 (gmt 0)

10+ Year Member



the script is working fine in delaying this part
"click here to continue"

but i want to delay another part of the page which is a Google adsense code "javascript"

*** i tried to use the same script again "in the same page" but it didn't work "because the adsense code is javascript"

whoisgregg

3:06 pm on May 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ahh, I understand. Although you could dynamically add in javascript with a timed function, in the case of google adsense that is definitely gonna get you in trouble with Google. (The terms of service prohibit any modification of their code and we would need to modify it to "inject" it later on in the page.)

However, if you put the adsense code in a div with an ID of "delayed_div" then you could toggle that div's display setting using the timer function. If you did that, it could be as simple as adding another conditional block inside your existing function:

if(c>8){ 
document.getElementById("delayed_div").style.display = 'none';
} else {
document.getElementById("delayed_div").style.display = 'block';
}