/    Sign up×
Community /Pin to ProfileBookmark

OnLoad, wait, then set variable to change DIV

Hi.

Here is the current code i have been using (taken snippets from multiple different codes across the net)-

[code=html]<SCRIPT>
window.onload = setTimeout(function() {variable=1}, 10000);

if(variable == 0){
document.write(“<DIV STYLE=’visibility:hidden; position:absolute;’>”);
}

else{
document.write(“<DIV STYLE=’visibility:visible; position:absolute;’>”);
}
</SCRIPT>

Text that will be affected</div>[/code]

I need it so that on loading the page, variable=0 so that the div is not visible, then after 10 seconds, the variable=1 so that the div is visible.

I hope you can help…

Thanks, Ryan.

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@slaughtersSep 10.2008 — [code=html]<SCRIPT>
window.onload = setTimeout(function() {showIt()}, 10000);
document.write("<DIV STYLE='display:none; position:absolute;'>");

function showIt() {
document.write("<DIV STYLE='display:block; position:absolute;'>");
}
</SCRIPT>[/code]

Or if DIV exists all ready with an ID assigned to it like this

[code=html]<div id="Content" style="display:none">
Stuff stuff stuff
</div>[/code]

then the javascript code is even simpler:

[code=html]<SCRIPT>
window.onload = setTimeout(function() {document.getElementById("Content").style.display="block"}, 10000);
</SCRIPT>[/code]
Copy linkTweet thisAlerts:
@ryani210693authorSep 10.2008 — It works a charm Slaughters!!

Thanks very much...the second part was extemerly useful.

Much appreciated.

Thanks, Ryan.
×

Success!

Help @ryani210693 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...