Dusan Czupek's blog

Blog related .NET, Android & web development

Recent posts

Tags

Categories

Navigation

Pages

    Archive

    Blogroll

      Disclaimer

      The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

      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, 11:57 by dczupek | Comments (2) RSS comment feed |
      • Currently 1/5 Stars.
      • 1
      • 2
      • 3
      • 4
      • 5
      Filed under: dotNet

      Comments (2) -

      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, 13: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, 15:08

      Pingbacks and trackbacks (1)+

      Comments are closed