javascript e asp

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

    javascript e asp

    I don't understund this script (i'm italian and speek english not very well)

    <script language="javas cript">
    var browser='';
    browser=navigat or.appName;
    document.cookie = "ScreenSize =" + screen.width + "-" + screen.height;
    document.cookie = "Browser=" + browser;
    </script>
    <%
    response.write( Request.Cookies )
    %>
    The cookie is write at first time but with the asp script i can read only
    after one refresh.
    Someone has the solution?

    Thanks Max



  • Evertjan.

    #2
    Re: javascript e asp

    Maxb wrote on 27 sep 2004 in comp.lang.javas cript:
    [color=blue]
    > I don't understund this script (i'm italian and speek english not very
    > well)
    >
    > <script language="javas cript">
    > var browser='';
    > browser=navigat or.appName;
    > document.cookie = "ScreenSize =" + screen.width + "-" +
    > screen.height; document.cookie = "Browser=" + browser;
    > </script>
    > <%
    > response.write( Request.Cookies )
    > %>
    > The cookie is write at first time but with the asp script i can read
    > only after one refresh.
    > Someone has the solution?[/color]

    There is nothing wrong here, Max, so there is no solution.

    ASP runs on the server BEVORE the page gets to the browser,
    so the refresh is necessary to read the cookie.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress,
    but let us keep the discussions in the newsgroup)

    Comment

    • Michael Powe

      #3
      Re: javascript e asp

      >>>>> "Maxb" == Maxb <NOSPAM_max@max b.net> writes:

      Maxb> I don't understund this script (i'm italian and speek
      Maxb> english not very well) <script language="javas cript"> var
      Maxb> browser=''; browser=navigat or.appName; document.cookie =
      Maxb> "ScreenSize =" + screen.width + "-" + screen.height;
      Maxb> document.cookie = "Browser=" + browser; </script> <%
      Maxb> response.write( Request.Cookies ) %> The cookie is write at
      Maxb> first time but with the asp script i can read only after one
      Maxb> refresh. Someone has the solution?

      I think the answer is that you are looking at the properties of the
      Request object, but on the first page request there are no cookies.

      When a page is requested by the browser, it sends to the server all
      the cookies it holds that are associated with that page. Those
      cookies will be then viewable as a property of the Request Object in
      ASP. But on the first request for the page, those cookies will not be
      in the browser's cookie jar; thus, nothing will be sent, and so that
      property of the Request Object will be empty. When you "refresh," the
      cookies are available and are sent as part of the page request. They
      now are viewable through the Request Object.

      mp

      --
      Michael Powe michael@trollop e.org Naugatuck CT USA
      "Usenet is like a herd of performing elephants with diarrhea --
      massive, difficult to redirect, awe-inspiring, entertaining, and a
      source of mind-boggling amounts of excrement when you least expect
      it." -- Gene Spafford

      Comment

      Working...