Forum Moderators: coopster

Message Too Old, No Replies

header("location: $url) problem with internal links

works with firefox and "sometimes" with IE

         

smagdy

1:05 pm on Dec 1, 2006 (gmt 0)

10+ Year Member



Hello,

I asked about this problem like 6 months ago but didnt reach a solution and i ignored it, but now while writing some script i needed to use it again!

So the problem is that this line down works fine with firefox but in IE6 & 7 it just goes to the url ignoring anything from # till end so it just goes to the url without jumping to the internal link but if i manually added the internal link in the url.. it will normally go to it! but the strange thing is that same line worked in other php files on same server!

PHP version 5.1.2

header("Location: h**p://www.mysite.se/somefile#a");

also doesnt work in any of the following cases!

-----------------------------------------------

header("Location: h**p://www.mysite.se/somefile.htm#a");
-----------------------------------------------

$h = '#a';
$url = $_SERVER['HTTP_REFERER'].$h;

session_write_close();
header("Location: ".$url);
exit;
---------------------------------------------

But all works in firefox!

Thanks in advance

coopster

5:17 pm on Dec 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



How do you have the anchor named in your HTML document? On the name attribute, or on the id attribute? Perhaps that is it. Is the named anchor fragment coming up in the address bar in IE?

smagdy

5:41 pm on Dec 1, 2006 (gmt 0)

10+ Year Member



Hello,

Its written like this:

<A NAME="a">&nbsp;</A>

and its not coming up in the adress bar but as i said before coming up in the firefox adress bar!

Thanks

Psychopsia

5:45 pm on Dec 1, 2006 (gmt 0)

10+ Year Member



Hello, try using just:

<a name="a"></a>

I use in this way when needed and works fine.

smagdy

6:42 pm on Dec 1, 2006 (gmt 0)

10+ Year Member



Hello,

It didnt work because the problem is not in the HTML page, if i write it manually then it goes there..

The problem is that when i redirect to this url:

www.mysite.com/page#a

it just goes to:

www.mysite.com/page ignoring the #a

so this let me say its bug in PHP but since it works in Firefox so that makes me say its bug in IE but because it works well in Firefox & IE in other pages that i have on same server so it makes me clueless!

coopster

7:19 pm on Dec 1, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Here is an old document that has some relative discussion on URI fragments and the authoritative docs, for what it is worth ...
Parse URL with a hashmark (#) [webmasterworld.com]

However, I just ran a test header() redirection with a fragment identifier and it worked just fine in both FF and MSIE. The new page was loaded and both browsers took me to the point halfway down the HTML document where the named anchor existed.

smagdy

9:37 pm on Dec 1, 2006 (gmt 0)

10+ Year Member



Thanks but it didnt help though it seems that he had my exact problem!