Forum Moderators: open
I want a page to load containing the message "you have been logged out" and I want this text to appear for only 10 seconds and then it should disappear
I can't use something to refresh the page like <META content="10; URL=login.php" http-equiv=Refresh> because it would interrupt the user from working on that page
var myTimeout;
function timedchange(id, newClass)
{ myTimeout = window.setTimeout(function() {document.getElementById(id).className=newClass;}, 2000);}
Here is the (X)HTML associated with the script...
<element onevent="timedchange('mymenu', 'hidemenu');"
- John
Assuming it's javascript, I've probably put the script in the wrong place or made a syntax error.
The text appears and stays permanently on screen.
What I have inserted into an HTML page is this:
<html><head><title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><SCRIPT language=JavaScript>
var myTimeout;
function timedchange(id, newClass)
{ myTimeout = window.setTimeout(function() {document.getElementById(id).className=newClass;}, 2000);}
</SCRIPT>
</head>
<body>
<p onevent="timedchange('mymenu', 'hidemenu');"> you have been logged out </p>
</body>
Your script tag is outdated (the language attribute is invalid). Use this for script tags instead:
<script type="text/javascript">
<html><head><title>test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
.removed {
display: none;
}
</style>
<script type="text/javascript">
window.onload = function() {
var myTimeout = window.setTimeout(function() {
document.getElementById('loggedOutMsg').className = 'removed';
}, 10000);
};
</script>
</head>
<body>
<p id="loggedOutMsg">You have been logged out</p>
</body>
</html>