469,306 Members | 2,512 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,306 developers. It's quick & easy.

asp javascript HTTP_REFERER is or is not undefined?

Hi All!

I have the following in an ASP script:

var bounceBackPage = Request.ServerVariables("HTTP_REFERER");
Response.Write("<p>bounceBackPage: " +
bounceBackPage + ". Undefined? " +
(bounceBackPage == "undefined") + " </p>");

When I enter the page URL by itself, I expect HTTP_REFERER to be undefined..
but this is the output I get:

bounceBackPage: undefined. Undefined? false

How can it print "undefined" and still return false for bounceBackPage ==
"undefined"?

Any advice would be most appreciated!

Rob
:)
Jul 19 '05 #1
9 3728
Did this to solve my problem..

bounceBackPage + "" == "undefined"
which returns true.

Rob
:)
"Robert Mark Bram" <none> wrote in message
news:41***********************@news.optusnet.com.a u...
Hi All!

I have the following in an ASP script:

var bounceBackPage = Request.ServerVariables("HTTP_REFERER");
Response.Write("<p>bounceBackPage: " +
bounceBackPage + ". Undefined? " +
(bounceBackPage == "undefined") + " </p>");

When I enter the page URL by itself, I expect HTTP_REFERER to be undefined.. but this is the output I get:

bounceBackPage: undefined. Undefined? false

How can it print "undefined" and still return false for bounceBackPage ==
"undefined"?

Any advice would be most appreciated!

Rob
:)

Jul 19 '05 #2
*Robert Mark Bram* wrote:
*Robert Mark Bram* wrote:
I have the following in an ASP script:

var bounceBackPage = Request.ServerVariables("HTTP_REFERER");
Response.Write("<p>bounceBackPage: " +
bounceBackPage + ". Undefined? " +
(bounceBackPage == "undefined") + " </p>");

When I enter the page URL by itself, I expect HTTP_REFERER to be
undefined.. but this is the output I get:

bounceBackPage: undefined. Undefined? false

How can it print "undefined" and still return false for
bounceBackPage == "undefined"?


Did this to solve my problem..

bounceBackPage + "" == "undefined"
which returns true.


Do you understand why though?

var objReferrer = Request.ServerVariables("HTTP_REFERER");
var strReferrer = objReferrer.Count() ? objReferrer.Item(1) : "";
--
Andrew Urquhart
- FAQ: www.jibbering.com/faq/
- Archive: www.google.com/groups?q=comp.lang.javascript
- Contact me: http://andrewu.co.uk/contact/
- Apologies for the wrong timestamp on my post - blame my ISP
Jul 19 '05 #3
ASP includes a type/bug where they misssssspell the server variable
HTTP_REFERER as HTTP_REFERRER

"Andrew Urquhart" <us**************************@spam.invalid> wrote in
message news:a9***************@newsfe5-gui.ntli.net...
*Robert Mark Bram* wrote:
*Robert Mark Bram* wrote:
I have the following in an ASP script:

var bounceBackPage = Request.ServerVariables("HTTP_REFERER");
Response.Write("<p>bounceBackPage: " +
bounceBackPage + ". Undefined? " +
(bounceBackPage == "undefined") + " </p>");

When I enter the page URL by itself, I expect HTTP_REFERER to be
undefined.. but this is the output I get:

bounceBackPage: undefined. Undefined? false

How can it print "undefined" and still return false for
bounceBackPage == "undefined"?


Did this to solve my problem..

bounceBackPage + "" == "undefined"
which returns true.


Do you understand why though?

var objReferrer = Request.ServerVariables("HTTP_REFERER");
var strReferrer = objReferrer.Count() ? objReferrer.Item(1) : "";
--
Andrew Urquhart
- FAQ: www.jibbering.com/faq/
- Archive: www.google.com/groups?q=comp.lang.javascript
- Contact me: http://andrewu.co.uk/contact/
- Apologies for the wrong timestamp on my post - blame my ISP

Jul 19 '05 #4
*Marlo Brandon* wrote:
"Andrew Urquhart" wrote:

[ Work around for Request.ServerVariables("HTTP_REFERER") not being a
string ]
Do you understand why though?

var objReferrer = Request.ServerVariables("HTTP_REFERER");
var strReferrer = objReferrer.Count() ? objReferrer.Item(1) : "";


ASP includes a type/bug where they misssssspell the server variable
HTTP_REFERER as HTTP_REFERRER


The HTTP spec has the misspelling, it's carried over into ASP and a
dozen other languages/frameworks. In what way does this assist the OP
though?
--
Andrew Urquhart
- Contact me: http://andrewu.co.uk/contact/
- Apologies for the wrong timestamp on my post - blame my ISP
Jul 19 '05 #5
On Mon, 2 Aug 2004 06:12:12 -0600, "Marlo Brandon"
<Ma**********@MarloBrandon.com> wrote:
in <NY********************@comcast.com>
ASP includes a type/bug where they misssssspell the server variable
HTTP_REFERER as HTTP_REFERRER


I don't what dictionary you use but the Webster's Encyclopedic
Unabridged Dictionary of the English Language shows ~referrer~ as
the CORRECT spelling of the word.
---
Stefan Berglund
Jul 19 '05 #6
> I don't what dictionary you use but the Webster's Encyclopedic
Unabridged Dictionary of the English Language shows ~referrer~ as
the CORRECT spelling of the word.


Why is this suddenly about English? Sheesh.

Anyway, the correct spelling of the word is REFERRER. The serverVariable
implemented by many web servers is HTTP_REFERER... *it* is what is
misspelled.

--
http://www.aspfaq.com/
(Reverse address to reply.)
Jul 19 '05 #7
Robert Mark Bram wrote:
Hi All!

I have the following in an ASP script:

var bounceBackPage = Request.ServerVariables("HTTP_REFERER");
Response.Write("<p>bounceBackPage: " +
bounceBackPage + ". Undefined? " +
(bounceBackPage == "undefined") + " </p>");

When I enter the page URL by itself, I expect HTTP_REFERER to be
undefined.. but this is the output I get:

bounceBackPage: undefined. Undefined? false

How can it print "undefined" and still return false for
bounceBackPage == "undefined"?

Any advice would be most appreciated!


You can certainly test this condition instead:
(typeof Request.ServerVariables("HTTP_REFERER").Item == "undefined")

If you prefer implicit boolean conversion, you can use this:
(Request.ServerVariables("HTTP_REFERER").Item || "undefined")

--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jul 19 '05 #8
> I don't what dictionary you use but the Webster's Encyclopedic
Unabridged Dictionary of the English Language shows ~referrer~ as
the CORRECT spelling of the word.
It's not a "word" it is an "identifier". Try this reference work (search the
page for "referer")
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Stefan Berglund" <ke****@in.thegroups> wrote in message
news:rd********************************@4ax.com... On Mon, 2 Aug 2004 06:12:12 -0600, "Marlo Brandon"
<Ma**********@MarloBrandon.com> wrote:
in <NY********************@comcast.com>
ASP includes a type/bug where they misssssspell the server variable
HTTP_REFERER as HTTP_REFERRER


I don't what dictionary you use but the Webster's Encyclopedic
Unabridged Dictionary of the English Language shows ~referrer~ as
the CORRECT spelling of the word.
---
Stefan Berglund

Jul 19 '05 #9
On Mon, 2 Aug 2004 13:31:31 -0400, "Aaron [SQL Server MVP]"
<te*****@dnartreb.noraa> wrote:
in <ea*************@tk2msftngp13.phx.gbl>
I don't what dictionary you use but the Webster's Encyclopedic
Unabridged Dictionary of the English Language shows ~referrer~ as
the CORRECT spelling of the word.


Why is this suddenly about English? Sheesh.

Anyway, the correct spelling of the word is REFERRER. The serverVariable
implemented by many web servers is HTTP_REFERER... *it* is what is
misspelled.


That is clearly obvious but that is not what was stated in the
post I replied to.

Thank you for reiterating exactly what I said. I am well aware
of the distinction between the ~word~ and the ~identifier~ and
had you quoted the additional two lines that I replied to, that
would have been intuitively obvious to the most casual observer.

Obviously, it's of little consequence either way, but in the
future I'll refrain from reacting to blatantly incorrect
statements especially when they're made by dead people.
---
Stefan Berglund
Jul 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Muffinman | last post: by
2 posts views Thread by Brian | last post: by
9 posts views Thread by Robert Mark Bram | last post: by
8 posts views Thread by mrsmithq | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.