-
January 26th, 2005, 09:05 PM
#1
Pause then redirect in PHP?
I've tried this with headers and with a javascript. The issue I'm running into is that the page is redirected before the user has a chance to read the page (page isn't even loaded). I'm trying to find a way to have a 5 second pause so the reader can see text before the page gets redirected. I've tried using the sleep() function but the page isn't seen.
I'm open to suggestions (this is for PHP 4.x)
-
January 26th, 2005, 09:10 PM
#2
Meta tags are your best friend.
http://www.indiana.edu/~wmhome/tool_..._metatag.shtml
Have a glorious day.
-
January 26th, 2005, 10:20 PM
#3
PHP is a HTML preprocessor. That's why your sleep-function doesn't work as intended. The HTML takes longer to be generated, but after that, you're forwarded just as fast.
;TT's link will solve your problem, but if you need another example, look at the source of a redirect-page of antionline (the 'your search is in progress' screen, for example). They work on the same principle - metatags. There's even some added javascript, but I'm not quite sure if that'll work.
I wish to express my gratitude to the people of Italy. Thank you for inventing pizza.
-
January 27th, 2005, 08:13 AM
#4
Hi
As Guus said, PHP is a server-side scripting language. In addition to the meta-tag method,
you might use something like
Code:
<script type="text/javascript"><!--
setTimeout('document.location="http://www.google.com"',5000);
--></script>
if you prefer javascript rather than meta-tags. Note, that there can
be reasons to use such a method.
The example will show the page containing that javascript-snippet for
5000 milliseconds, then it will redirect to google.com
Cheers
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
-
January 28th, 2005, 07:56 AM
#5
I would go with the javascript function. I have used it on a few different occasions when in a jam like this.
- MilitantEidolon
Yeah thats right........I said It!
Ultimately everyone will have their own opinion--this is mine.
-
January 28th, 2005, 09:12 AM
#6
Why? Is there any (used) browser left that doesn't correctly implement the meta-tag solution? I prefer that over javascript any day - it's simpler, so you're less likely to make some mistake and it's easier to maintain.
I wish to express my gratitude to the people of Italy. Thank you for inventing pizza.
-
January 28th, 2005, 09:28 AM
#7
Hi Guus
I actually used both approaches. However, it might be a matter of ignorance, but I used
the javascript-version for the following reason:
I have a loader-page, which determines several issues, like CSS version, DOM, screen width-height
etc. on the client-side, and then redirects to a new page, while passing these information.
On server-side (after verification), then a very customized web-page is created and sent.
If this can be solved easier (bandwidth, performance etc. issues), I would be happy to learn
about it. This was a quick hack in the beginning, but has proven to be quite useful
Cheers
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
-
January 28th, 2005, 09:39 AM
#8
I have a loader-page, which determines several issues, like CSS version, DOM, screen width-height etc. on the client-side, and then redirects to a new page, while passing these information. On server-side (after verification), then a very customized web-page is created and sent.
Sounds like a totally legit solution, however it sounds like a lot unless you are seriously dependent on css version, DOM, res, and so on. Good CSS, html, liquid layouts, should be very renderable across the big browsers without all kinds of detection. However I can't speak for your specific situation so do whatever works, but redirects on webpages are kind of annoying from a user prespective.
-
January 28th, 2005, 10:11 AM
#9
true, both of you. I was just thinking of plain redirect though, not detecting anything. Javascript can be very useful, but I try to avoid it when I don't need it. That's also a bit of a personal grudge on my side.
I wish to express my gratitude to the people of Italy. Thank you for inventing pizza.
-
February 3rd, 2005, 04:37 PM
#10
Member
I think just the redirect from a meta tag would be plenty. Especially since you can set the time to be what ever you want it to be. I agree that redirects can be annoying, but it depends upon how they are handled, and why they happen. For example, redirecting you from one section of a site to another based on your settings, etc. wouldn't be to bad, because you wouldn't really see the redirect, unless it wanted you to.
I would handle it like this...
<?php
do some stuff for the verification and print stuff,
<meta http-equiv="refresh" content="some number of seconds; URL=foo.php"/>
?>
Because it's simple (one line of code), data can be maintained in session to cross pages, and all you have to do to change the amount of time it waits is change one part of the meta tag, and it happily does it.
and in the process it prints what you have in the script then does the redirect when it's ready to. JavaScript is another good solution, but I'm thinking along the lines of efficiency regarding LOC and development time.
--BigDick
\"When in Rome, eat Rome!\" -Godzilla
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|