Dusan Czupek's blog

Blog related .NET & web development

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

Microsoft announced fix will be from IE9. Until you can avoid problems with following 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
  }
}

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 some versions of 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.
Posted: Aug 05 2009, 12:57 by dczupek | Comments (27) RSS comment feed |
  • Currently 1/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Filed under: dotNet

Comments

DotNetKicks.com said:

trackback.NET Programming: Request.UrlReferrer Is Null In IE 6.0 when location.

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# August 20 2009, 20:11

Boiler insurance United Kingdom said:

Boiler insuranceI have recently set out to develop using Javascript in the client browser but  am finding it is a large learning curve.  The title " RequestUrlReferrer Is Null In IE 60 " in this post, okay that made me curious. My recent experience is with mysql, php, most linux based tools and a little flash with actionscript. The ambition of using Javascript to produce a good client script that functions quickly in most of the established web browsers, Internet Explorer, Safari, Firefox and Google Chrome seems a great head ache which is taking me umpteen hours to master.  I find the tutorial web sites  are often inert and cover the same items, dialog in blogs oftentimes reference genuine methods to beat issues which takes me through the learning curve more quickly. Engrossing to read your thoughts and the comments in your website on Javascript. Thanks for the note, it has assisted in a small way to take me through the migration.

# October 02 2009, 14:25

Annuities United States said:

AnnuitiesThe code you provide really effective. I'm using javascript to creates  more client script that generate in established web browser. Thanks for your note.

# October 18 2009, 16:08

online pharmacy United States said:

online pharmacy This sure has helped me out...Saved me hours.

# November 13 2009, 23:42

Business Class Flights United Kingdom said:

Business Class FlightsGreat javascript info. Still, I wish IE would be at least as compatible as Firefox. Hopefully IE9 will be a big improvement!

# December 06 2009, 17:35

melayuboleh Australia said:

melayubolehExcellent read. Very insightful. I'm kind of new to the world of blogging, this will definately help.

# December 08 2009, 01:15

hirephpdevelopers United States said:

hirephpdevelopersNice information about location.href function. It is giving brief information about this function.

# December 09 2009, 16:55

ffxi guide United States said:

ffxi guideThank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.

# December 09 2009, 17:37

corolle dolls United States said:

corolle dollsCouldn?t be written any better. Reading this post reminds me of my old room mate! He always kept talking about this. I will forward this article to him. Pretty sure he will have a good read. Thanks for sharing!

# December 10 2009, 21:40

SEO Reseller United States said:

SEO Reseller We're just about a month after the Windows 7 launch, and wanted to show an early look at some of the work underway on Internet Explorer 9.

# December 14 2009, 08:54

Bikes Thailand said:

BikesNice post.

# December 17 2009, 13:55

black short sleeve sweater United Kingdom said:

black short sleeve sweaterI was rationalizing on this issue last evening and I determined to search the WWW for some info. Your blog came up in my research and Im impressed with what you have penned on this topic.

# December 26 2009, 19:16

Hidup Berani Untuk Gagal Australia said:

Hidup Berani Untuk GagalThanks for the post. I've been really interested in Flikr and how Yahoo uses those pictures in a lot of it's image search results.

# January 08 2010, 14:08

how to get rid of pimples United States said:

how to get rid of pimpleswanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post


Regards
Clark







# January 09 2010, 14:58

Aku Cuma Seorang Blogger Yang Cinta Seo United States said:

Aku Cuma Seorang Blogger Yang Cinta SeoNice information, valuable and excellent design, as share good stuff with good ideas and concepts, lots of great information and inspiration, both of which we all need, thanks for all the enthusiasm to offer such helpful information here.

May exchange link ?

# January 10 2010, 15:00

health insurance quote United States said:

health insurance quoteHaving trouble with IE browsers.. My codes didn't work in some reasons..

# January 12 2010, 21:23

sikat ang pinoy United States said:

sikat ang pinoyYour website came up in my search and I'm taken by what you have composed on this topic. I am presently diversifying my research and thus cannot contribute further, even so, I've bookmarked your web site and will be returning to keep up with any future updates. Just Now love it and thanks for granting my remark. Great job and will extend it on to admirers and my web site fans.

# January 13 2010, 05:52

Fullerton Criminal Defense United States said:

Fullerton Criminal DefenseHappy to see your blog as it is just what I’ve looking for and excited to read all the posts.I am looking forward to another great articles from you..

# January 14 2010, 23:31

top casinos Spain said:

top casinos
Thanks, your blog is very interesting!

# January 21 2010, 23:57

khg casinos Spain said:

khg casinos
Thanks, your blog is very interesting!

# January 21 2010, 23:57

video chat software United States said:

video chat software  I really appreciate posts, which might be of very useful for beginners in blogging as I am. I already have a small collection of blog posts and other articles, from which I step by step learn various aspects of life. Thank you for your resource.

# January 23 2010, 08:04

Hot Information United States said:

Hot InformationThis is my first time i visit here. I found so many interesting stuff in your blog especially its discussion. From the tons of comments on your articles, I guess I am not the only one having all the enjoyment here! keep up the good work.

# January 23 2010, 15:04

Office supplies People's Republic of China said:

Office suppliesnice post. keep on your good work. I've bookmarked your web site and will be returning to keep up with any future updates

# January 27 2010, 01:44

Buenos Aires real estate guide United States said:

Buenos Aires real estate guideAlways interesting posts, congrats for the great results, congrats Dusan.

# January 28 2010, 07:36

stretchmark Iceland said:

stretchmarkYour posting very useful for me
thanks and keep writing.

happy blogging

# February 01 2010, 12:29

Budget Van Lines United States said:

Budget Van Linesjavascript can be so messy sometimes

# February 10 2010, 20:16

reg clean New Zealand said:

reg cleanThank you for a great post.  Really enjoyed reading it, and will be back for more when I have time.

# February 19 2010, 07:54

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading