Click to See Complete Forum and Search --> : Meta Tag Refresh Page


spykemitchell
09-20-2003, 03:26 PM
I have allready posted this but noone took any notice.

I want a meta tag that i can put in an html document that will refresh the page it is on once without specifying an url.

whenever i don't specify an url it just refreshes over and over again which is obviously not what i want...

Can anyone help?

Spyke.

AdamGundry
09-20-2003, 03:55 PM
A meta tag on its own cannot do this, because it simply causes a page refresh after x seconds. You need to add code either on the client or server-side which tests if this is the first or second display of the page.

You can do this client-side with Javascript, but a server-side script (using a language such as PHP) would be much more reliable.

PHP solution (add this where you would add the meta tag, untested):
<?php if (!isset($_GET['reloaded'])) echo '<meta http-equiv="refresh" content="10; URL=filename.php?reloaded=true;">'; ?>

Javascript solution (ditto):
<script type="text/javascript">
if (location.search != '?reloaded=true'){
setTimeout('window.location = "filename.html?reloaded = true"', 10 * 1000);
}
</script>

spykemitchell
09-20-2003, 05:40 PM
Oh, I see.... Thankyou for that!

spykemitchell
09-20-2003, 05:42 PM
still have to specify an url though...

AdamGundry
09-21-2003, 02:24 PM
Sorry, I misinterpreted your post. Perhaps one of these might work?

<?php if (!isset($_GET['reloaded'])) echo '<meta http-equiv="refresh" content="10; URL=' . __FILE__ . '?reloaded=true;">'; ?>

<script type="text/javascript">
if (location.search != '?reloaded=true'){
setTimeout('window.location = window.location + "?reloaded = true"', 10 * 1000);
}
</script>

Adam