I've got an url http://www.example.com/?req=welcome
.
To get the parameter req
I use PHP like this:
echo $_GET['req'];
This will show the message in the body but this output should vanish after a second.
How do i do that?
I've got an url http://www.example.com/?req=welcome
.
To get the parameter req
I use PHP like this:
echo $_GET['req'];
This will show the message in the body but this output should vanish after a second.
How do i do that?
<div id='req'><? echo $_GET['req']; ?></div>
Then use JavaScript:
window.addEventListener('load', function (){
setTimeout(function (){
document.getElementById('req').textContent = '';
}, 1000); // 1000 is 1s. Set this to how many seconds you want to allow the request to be displayed for.
});
You would use javascript.
You can see an example of that here, using jquery. It's possible to do it without that framework (or any framework). .delay would be replaced by setTimeout() which would enclose your fade out function.
You can't - PHP is a server-side language, it has no control over the browser after it finishes sending the output.
Note that you could put your echoed code into a HTML element like a div
, and hide it with JavaScript some time after the page loads. Example using jQuery for simplicity:
<div id="hidethisafterawhile"><?php echo $_GET['req']; ?></div>
<script type="text/javascript">
$(document).ready(function() {
window.setTimeout(function(){
$("#hidethisafterawhile").hide();
},1000);
});
</script>