How to get javascript to read new value of sessionvariable.

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default How to get javascript to read new value of sessionvariable.

    - From page 1, I initialize session variable A to 0
    - On page 2, I use javascript to launch a popup windown if session variable A
    = 0. After that, I change session variable A to 1. My intention is to not
    show the popup again when user navigates back to page 2.
    - However, when user submits the page to to go page 3 and uses the browser
    back button to navigate back to page 2, the popup window is brought up again.

    Is there a way to force the javascript to source the new value of the session
    variable so that the popup doesn't come up again? Or may be there a different
    way to handle this? Please advice. Thanks.

    spham Guest

  2. Similar Questions and Discussions

    1. Include javascript in a javascript file
      Hello, Is there a way to include a javascript file from WITHIN a javascript file? Something similar as in the "#include" directive in C++? ...
    2. output text in control location; calling control javascript from page javascript
      Hi; If you don't know, I'm just learning javascript and aspnet, but I have a pretty good grounding in windows programming. I'm trying to build a...
    3. need javascript staff (anyone who knows javascript peroid) (READ)
      hey its me ultimategamerx and im back in some clothes lol i need some people who know java script i need help please reply if ya know some
    4. File system get auto change from read-write to read-oly
      I have a very strange file system with OS Redhat 7.2 The file system is read-write, but some how it randomly changes to read-only at any time....
    5. Read & Read/Write Groups
      I am trying to achieve a solution to a (hopefully) simple scenario. I have a Solaris 9 server that is going to be used for sharing files. I...
  3. #2

    Default Re: How to get javascript to read new value of sessionvariable.

    Spham,
    As I understand it when the user clicks the back button, the page is loaded
    from their browser cache. Since no server side processing is involved the
    session varaible remains as a value of 0. The best workaround would be have
    your page 2 reload itself immediately after the pop-up is displayed (using
    javascript and after the session variable has been changed). Then when the user
    moves on to page 3, the back button will reload the second display of page 2,
    where the session variable has already been change to 1.
    The alternative is to try and disable the use of the back button (opening
    the browser using javascript with toolbar and mneubar set to no).


    GGRam Guest

  4. #3

    Default Re: How to get javascript to read new value of sessionvariable.

    When I reload the page, I get the message that says "The page cannot be
    refreshed without resending the information. Click Retry to send the
    informaiton again, or click Cancel to return to the page that you were trying
    to view." Is there a way to avoid this confirmation window?

    spham Guest

  5. #4

    Default Re: How to get javascript to read new value of sessionvariable.

    I dont know if this will work, but what if you told the browser not to cache
    the page by using something along the line of....

    <cfheader name="Pragma" value="no-cache">
    or
    <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">

    This way the browser you go back to the server for the document and would
    receive a new copy where your session var is now 1....

    Just an idea...good luck!

    jeby Guest

  6. #5

    Default Re: How to get javascript to read new value of sessionvariable.

    How did you use Javascript to change the coldfusion session variable that you describe?

    thanks,
    matt
    roadsend Guest

  7. #6

    Default Re: How to get javascript to read new value of sessionvariable.

    You can also set a cookie on the client side to control the popup when the user
    clicks on the back button.

    Here is an example using your scenario:



    <!--- page1.cfm --->
    <html>
    <body onLoad="document.cookie='A=0'">

    PAGE 1<br>
    <a href="page2.cfm">Goto Page 2</a><br>

    </body>
    </html>


    <!--- page2.cfm --->
    <html>
    <head>
    <script language='JavaScript'>
    function popup()
    {
    if ( document.cookie == "A=0" )
    {
    document.cookie = "A=1";
    window.alert('hello');
    }
    }
    </script>
    </head>

    <body onLoad="popup()">

    PAGE 2<br>
    <a href="page3.cfm">Goto Page 3</a><br>

    </body>
    </html>


    <!--- page3.cfm --->
    <html>
    <body>

    PAGE 3<br>
    <a href="page1.cfm">Go back to Page 1</a>

    </body>
    </html>

    eastinq Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139