opera redirect not working

For some reason Opera cannot handle having an anchor in a URL to redirect. I wrote a simple test with a form that has a single hidden field containing a URL with an anchor. When submitted, the form sends the hidden value to be used in a call to the header function, which is supposed to redirect the user to the new URL. It works fine in the other browsers I’ve tested, but for some reason in Opera it just sits waiting forever (or at least several minutes. I haven’t been willing to wait any longer)

Maybe there’s a way to make it work, but I’ve tried escaping the # sign with an HTML character entity, but I got the same behavior. If anyone has any ideas about why Opera doesn’t work with the anchor in the URL I’d be very interested in hearing them.

Here’s the code I used for the test:

<?php
$url = $_POST[ 'url' ];
header( "Location: $url" );
?>
<html>
<form method="post" action="test.php">
<input type="hidden" name="url" value="<?php echo $_SERVER[ 'PHP_SELF' ];
?>#bottom">
<input type="submit" value="Submit">
</form>

<div style="margin-top:500px;margin-bottom:1000px">
<a name="bottom"></a>
<h1>This is the bottom</h1>
</div>

</html>

Comments

 (Post a comment) | Comments RSS feed
  1. You may be interested in this thread where I’ve stumbled across a weird,(but not very elegant) fix for this:
    http://my.opera.com/forums/showthread.php?s=&postid=817237#post817237

    Hasta later,
    kamm…

    Comment by kamm on January 27, 2005 @ 1:45 pm
  2. Thanks for letting me know. I’m glad to see I wasn’t the only one seeing that problem but it’s too bad no one has found a cleaner solution.

    Comment by dan on January 27, 2005 @ 2:38 pm
  3. I commented on this over at http://bzabza.com/php/94/ basically Opera sees that it is the same page just with an anchor so it only tries to goto that anchor in the current page. Now adding a GET parameter to the redirect will force it to reload the page but it has the unfortunate side effect of leaving any forms filled in with the old data even employing every anti cache trick in the book.

    Comment by Jason Bainbriudge on August 31, 2005 @ 11:04 pm

Comments are closed