[FX.php List] PHP Header vs. Javascript location.replace ?

Kevin Futter kfutter at sbc.melb.catholic.edu.au
Wed Jul 19 16:51:48 MDT 2006

On 20/7/06 8:37 AM, "Joel Shapiro" <jsfmp at earthlink.net> wrote:

> Last year at DevCon Lance Hallberg recommended using a javascript
> location.replace instead of php header (something about problems
> loading a header more than once?)
> <script language="javascript">
> <!--
> location.replace("./Form2.php");
> -->
> </script>
> Any thoughts?
> -Joel

Anyone using any modern browser can turn JavaScript off, so please don't
rely on ANY JavaScript technique for basic or required functionality. It's
much better to handle this kind of redirect from the server. Multiple
headers can cause problems, but they will be fewer and more easily managed
than the corresponding JavaScript problems. People relying on assistive
technologies (screenreaders etc) for their browsing likely don't have access
to JavaScript at all.

If you do decide to use the above JS solution, just be aware that the HTML
comments surrounding the statement are redundant in a modern web setting,
and will in fact cause problems in a strict XHTML environment.

Kevin Futter
Webmaster, St. Bernard's College

This e-mail and any attachments may be confidential.  You must not disclose or use the information in this e-mail if you are not the intended recipient.  If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies.  The College does not guarantee that this e-mail is virus or error free.  The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not.  The content and opinions in this e-mail are not necessarily those of the College.

More information about the FX.php_List mailing list