473,406 Members | 2,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Combining Javascript and ASP question

Hi All,

Can someone please point me in the right direction I am having problems
combining JS and ASP. What I am trying to do is store in a database using
ASP the referring page of my visitors. I got the ASP working great and when
I use the document.referrer in an alert it works too, but when I try to
combine the 2 languages that is when I get an error that I cannot fix. Here
is the code fragment that is not working:

rs("ReferPage") = %> document.referrer <%

I have tried this as well :

rs("ReferPage") =%> <script language="javascript"
document.referrer></script> <%

Both the code fragments are embedded in the head of the asp page hence the
%> and <%.

I am probably missing something very basic but I am at a loss to think what
it could be. I have done some searching and could not find a suitable
tutorial. The only one I found talked about using an include file. Any
help would be welcomed.

Brian
Jul 20 '05 #1
2 2699
Brian wrote:
Can someone please point me in the right direction I am having problems
combining JS and ASP. What I am trying to do is store in a database using
ASP the referring page of my visitors. I got the ASP working great and
when I use the document.referrer in an alert it works too, but when I try
to
combine the 2 languages that is when I get an error that I cannot fix.
Here is the code fragment that is not working:

rs("ReferPage") = %> document.referrer <% I am probably missing something very basic but I am at a loss to think
what it could be.


ASP is a means of executing scripts on the server, JavaScript (in this
usage) is a client side language. The ASP runs on the server, the
JavaScript runs on the client. The direction of communication is from the
server to the client, not the other way round. To get data from JavaScript
to the server you have to make a new HTTP request containing the data.

Its a big was of time trying to do that for this though - as the referer
information is already exposed to ASP anyway (although I'll point out that
the referer header is optional so the browser doesn't have to provide it -
and some personal firewalls obscure the referer in the interests of privacy
(why they don't just discard it I don't know, malformed http requests help
nobody)).

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #2

Hi David,

Thank you for your response. From your feedback I went and did another
search online to look for an ASP solution and I changed my code to read :

refer= Request.ServerVariables("HTTP_REFERER")

That was it and it is working perfectly.What a relief. I am branching out
into creating more dynamic pages with Javascript and am making mistakes
along the way. I posted the above code to help anyone else who might be in
the same situation. I see too often someone with a cool problem and then
they simply post "Thanks I found the answer and it works great" or
something like that. LOL It doesn't help the rest of us out. I am using an
older book that I bought real cheap by Coriolis and it didn't have the
HTTP_REFERER as part of the Server Variables Collection. I guess I better
get out and look for a better reference too.

Thanks for the push in the right direction.

Brian


"David Dorward" <do*****@yahoo.com> wrote in message
news:br*******************@news.demon.co.uk...
Brian wrote:
Can someone please point me in the right direction I am having problems
combining JS and ASP. What I am trying to do is store in a database using ASP the referring page of my visitors. I got the ASP working great and
when I use the document.referrer in an alert it works too, but when I try to
combine the 2 languages that is when I get an error that I cannot fix.
Here is the code fragment that is not working:

rs("ReferPage") = %> document.referrer <%
I am probably missing something very basic but I am at a loss to think
what it could be.


ASP is a means of executing scripts on the server, JavaScript (in this
usage) is a client side language. The ASP runs on the server, the
JavaScript runs on the client. The direction of communication is from the
server to the client, not the other way round. To get data from JavaScript
to the server you have to make a new HTTP request containing the data.

Its a big was of time trying to do that for this though - as the referer
information is already exposed to ASP anyway (although I'll point out that
the referer header is optional so the browser doesn't have to provide it -
and some personal firewalls obscure the referer in the interests of

privacy (why they don't just discard it I don't know, malformed http requests help
nobody)).

--
David Dorward <http://dorward.me.uk/>

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris Mullins | last post by:
I've spent a bit of time over the last year trying to implement RFC 3454 (Preparation of Internationalized Strings, aka 'StringPrep'). This RFC is also a dependency for RFC 3491...
3
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I...
7
by: Barry | last post by:
Hi all, I've noticed a strange error on my website. When I print a capital letter P with a dot above, using & #7766; it appears correctly, but when I use P& #0775 it doesn't. The following...
3
by: Flip | last post by:
I'm looking at the O'Reilly Programming C# book and I have a question about extending and combining interfaces syntax. It just looks a bit odd to me, the two syntaxes look identical, but how does...
7
by: odysseus654 | last post by:
I have just discovered the "with" statement, which up until now I have only known as "that which should never be used". I would like to evaluate some commands (such as function definitions and the...
8
by: nkoriginal | last post by:
Hi: (this is a dummy question, I know, but I tried many times and I cant) I need to insert this javascript option inside the input, I can't insert any funtion in <head> I've this two...
4
by: Cosmichrist | last post by:
First of all, thank you in advance for any direction you can provide. I do appreaciate it very much. I am trying to combine two flash players which use java onto one page. I will list the text...
5
by: Tristan Miller | last post by:
Greetings. Is it possible using HTML and CSS to represent a combining diacritical mark in a different style from the letter it modifies? For example, say I want to render Å‘ (Latin small letter...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.