I'm wondering if someone could help me out with a script that hides a <div> a couple of seconds after the page is loaded. I have little to no experience in Java, so i'm not sure how to go about it.
Announcement
Collapse
No announcement yet.
How do i hide a <div> after a delay?
Collapse
X
-
Originally posted by Zyprexa View PostI'm wondering if someone could help me out with a script that hides a <div> a couple of seconds after the page is loaded. I have little to no experience in Java, so i'm not sure how to go about it.
with javascript you can do something like that:
Code:function hideit(){ var o = document.getElemenById('tohide'); o.style.display = 'none'; } window.onload = function(){ setTimeout("hideit()",5000); // 5 seconds after user (re)load the page };
Code:<div id="tohide"> ...... </div>
best regards
-
Could not get it to work
Could not get this to work
This is the code i tested:
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function hideit(){ var o = document.getElemenById('hidethisone'); o.style.display = 'none'; } window.onload = function(){ setTimeout("hideit()",5000); // 5 seconds after user (re)load the page }; </script> </head> <body> <div id="hidethisone"> THIS SHOULD VANISH </div> </body> </html>
Comment
-
Originally posted by Zyprexa View PostCould not get this to work
This is the code i tested:
Code:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function hideit(){ var o = document.getElemenById('hidethisone'); o.style.display = 'none'; } window.onload = function(){ setTimeout("hideit()",5000); // 5 seconds after user (re)load the page }; </script> </head> <body> <div id="hidethisone"> THIS SHOULD VANISH </div> </body> </html>
Code:var o = document.getElemen[ICODE]t[/ICODE]ById('hidethisone');
Comment
Comment