Forum Moderators: open

Message Too Old, No Replies

timed text

         

dtest

3:15 pm on Sep 22, 2007 (gmt 0)

10+ Year Member



is there a php command (or even a plain HTML one) that would allow a text to display for xx seconds?

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

JAB Creations

3:37 am on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is a class changer that implements a JavaScript timeout function. I think I have the timeout highlighted in red correctly..

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

dtest

11:00 am on Sep 24, 2007 (gmt 0)

10+ Year Member



Is that php or javascript?

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>

Fotiman

2:22 pm on Sep 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Anything that happens client side (in the user's browser, without going back to the server) is going to be JavaScript, not PHP.

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>

dtest

10:17 pm on Sep 24, 2007 (gmt 0)

10+ Year Member



that worked like a charm. cheers