Saturday July 31, 2010 @ 04:10:02 GMT+10    ( Weather:  18°C / 64°F  -  Partly Cloudy )
Home » Weblog Archives

Info *NOTE* This page is NOT the actual weblog entry. The purpose for this page is to provide extra background information on how this particular entry is constructed, by using custom markups and tags. To read the actual content of this entry, please go to here.

The Raw Structure:

Markup | Tag used: BBCode


It's pretty common in PHP where a header() function is used to redirect the user to a specify page.

[code=lang:php|highlight]
<?
header("Location: http://www.domain.com");
header("Refresh: 5; http://www.domain.com"); // Redirect after 5 secs
?>
[/code]

The above code will work perfectly. However, given a URI [b]http://www.domain.com/file01.php?do=something#anchorhere[/b]

[code=lang:php|highlight]
<?
// This won't work with Opera 7.54 or even earlier,
// or this never worked before in Opera up to 8.5
header("Location: http://www.domain.com/file01.php?do=something#anchorhere");
// No problem for this though
header("Refresh: 5; http://www.domain.com/file01.php?do=something#anchorhere");
// A method to overcome the problem in Opera
header("Refresh: 0; http://www.domain.com/file01.php?do=something#anchorhere");
?>
[/code]

Apparently, it's the '#anchorhere' in the URI that causes Opera failed to redirect to that page. According to the HTTP/1.1 protocol, there is no restriction for using #anchor for the URI inside the header's Location field. I haven't test this with IE and FireFox myself but there are reports saying both IE and FF are working fine.
For more info, click [url=http://my.opera.com/community/forums/topic.dml?id=88597]here[/url].

Live Rendering:

The real-time rendered result...

Last edited: Tue 2005-10-11 @ 01:56 , by DaRen 1 time(s)

Opera and PHP header() - 7:27 pm
Browser , Bug , PHP , Standards  -  poster 

It's pretty common in PHP where a header() function is used to redirect the user to a specify page.

[ Hide ]
[ Highlight ] [ Text ]
<?
header("Location: http://www.domain.com");
header("Refresh: 5; http://www.domain.com"); // Redirect after 5 secs
?>


The above code will work perfectly. However, given a URI http://www.domain.com/file01.php?do=something#anchorhere

[ Hide ]
[ Highlight ] [ Text ]
<?
// This won't work with Opera 7.54 or even earlier,
// or this never worked before in Opera up to 8.5
header("Location: http://www.domain.com/file01.php?do=something#anchorhere");
// No problem for this though
header("Refresh: 5; http://www.domain.com/file01.php?do=something#anchorhere");
// A method to overcome the problem in Opera
header("Refresh: 0; http://www.domain.com/file01.php?do=something#anchorhere");
?>


Apparently, it's the '#anchorhere' in the URI that causes Opera failed to redirect to that page. According to the HTTP/1.1 protocol, there is no restriction for using #anchor for the URI inside the header's Location field. I haven't test this with IE and FireFox myself but there are reports saying both IE and FF are working fine.
For more info, click here.
$ view_blog.php 2009.09.17 18:16:41 $
Lost? | XML/HTML sitemap | Contact
38.107.191.88 , 23 queries , 0.0652s
Gzip enabled , CSS compressed , JS compressed
Copyright © 2005-2009 Darren's Outpost