Request.UrlReferrer Is Null IN IE 6.0 when location.href(Javascript) is used to redirect

S

saden_paki

I am having this problem, that Request.UrlReferrer comes out to be
Nothing, when a user hits a button on a html page which only have this
button, on this button's onClick javascript event I have used
location.href to redirect the page to an aspx page, there I try to
extract the Request.UrlReferrer which comes out to be null..

When I used the mozilla based(firefox) I was able to get the
Request.UrlReferrer info.

is there anyway that I can get that info in IE, my problem is that I
can't replace the location.href way of redirection for the html page...

I know someone from you guys knows the solution... Just in search of
that guy... :) please help!
 
G

Guest

Hi Saden, I think that location.href is the eqivalent of the user typing the
url into the browser, in which case there is no referrer. You may need to use
window.navigate(url) (but said that you need to use location.href) perhaps
somebody else knows better? HTH jd
 
S

saden_paki

when used firefox, I got the Request.UrReferrer appropriate value,
thats why I posted it as a question, cant get the value for IE....
 
G

Guest

could you pass the referring url in the querystring e.g location.href =
'mypage.aspx?referrer=referringpage.aspx'
 
B

Bruce Barker

this is a unreliable approach as many proxy/firewall servers strip this
field from the request for security concerns.

-- bruce (sqlwork.com)
 
S

saden_paki

I may try this but I have got to paas the referrer along with the
querystrings, so is that achievable, i mean sending the whole url along
with its own querystring in another querystring. thanks
 
S

saden_paki

I am devloping an application that will be used over intranet, so I
believe that is not a real issue here...

Is this an IE bug, since I have been able to get things running
smoothly in FireFox...
 
Joined
Oct 18, 2008
Messages
1
Reaction score
0
Here's some script which seems to work around the location.href no-referrer problem in IE. The trick is that, although location.href navigation (and window.navigate() too) doesn't send a referrer, the IE-only click() method on a hyperlink will send a referrer. So if you create a hyperlink, set its href, and then click() it with script, you'll get the referrer you want.

Unfortunately the click() method isn't supported on hyperlinks in Firefox, so you need to check for its presence and use location.href if it's not there. Since location.href sends a referrer on firefox, it works fine.

Code:
function navigateWithReferrer(url)
{
    var fakeLink = document.createElement ("a");
    if (typeof(fakeLink.click) == 'undefined')
        location.href = url;  // sends referrer in FF, not in IE
    else
    {
        fakeLink.href = url;
        document.body.appendChild(fakeLink);
        fakeLink.click();   // click() method defined in IE only
    }
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top