Combining Javascript and ASP question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian

    #1

    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.referr er 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.referr er <%

    I have tried this as well :

    rs("ReferPage" ) =%> <script language="javas cript"
    document.referr er></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


  • David Dorward

    #2
    Re: Combining Javascript and ASP question

    Brian wrote:
    [color=blue]
    > 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.referr er 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.referr er <%[/color]
    [color=blue]
    > I am probably missing something very basic but I am at a loss to think
    > what it could be.[/color]

    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/>

    Comment

    • Brian

      #3
      Re: Combining Javascript and ASP question


      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.ServerV ariables("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" <dorward@yahoo. com> wrote in message
      news:brengk$ete $1$8302bc10@new s.demon.co.uk.. .[color=blue]
      > Brian wrote:
      >[color=green]
      > > 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[/color][/color]
      using[color=blue][color=green]
      > > ASP the referring page of my visitors. I got the ASP working great and
      > > when I use the document.referr er in an alert it works too, but when I[/color][/color]
      try[color=blue][color=green]
      > > 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.referr er <%[/color]
      >[color=green]
      > > I am probably missing something very basic but I am at a loss to think
      > > what it could be.[/color]
      >
      > 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[/color]
      privacy[color=blue]
      > (why they don't just discard it I don't know, malformed http requests help
      > nobody)).
      >
      > --
      > David Dorward <http://dorward.me.uk/>[/color]


      Comment

      Working...