Good day!

I just want to ask a little help on how to redirect the user to the previous page after 5 seconds?

Thank you!

Recommended Answers

All 3 Replies

I use onload

<body onLoad="setTimeout('delayer()', 5000)">
...
php
<?
function delayer(){
    header('Location: '.$_SERVER['HTTP_REFERER']);
}
?>
...
or javascript
<script>
function delayer(){
    window.history.go(-1);
}
</script>

thank you PsychicTide!

I tried your code above but it seems its not working on my side? What I did wrong? below is my implementation..

<?php 
function delayer(){
header('Location: '.$_SERVER['HTTP_REFERER']);
} ?>

<body onLoad="setTimeout('delayer()', 5000)" id="error-page">

PsychicTide, Ive implemented the JS and its working!.. Thank you! code below..

<script type="text/javascript">
function delayer(){
window.history.go(-1);
}
</script>

<body onLoad="setTimeout('delayer()', 5000)" id="error-page">

However this one works too with only one line of code..

<meta http-equiv="refresh" content="5;URL='<?php echo $_SERVER['HTTP_REFERER']; ?>'" />

Problem Solved.. Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.