472,353 Members | 1,360 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 2610
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...
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...
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...
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...
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...
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...
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...
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...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.