CF code in unload event

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default CF code in unload event

    I have some CF code that I want to execute when a user leaves a page. I put it
    in a javascript OnUnload routine. However the code seems to be executing when
    the page loads as well. I set the agent status = 'I', then load the page, and
    the status is set to 'O'. Does anyone know why this code executes before the
    unload event???? Thanks. function jsUnload(){ <CFOUTPUT> <CFQUERY
    NAME='qAgentPhone' DATASOURCE='#application.dsnCommon#'> UPDATE
    tblAgentStatus SET AgentIn = 'O' WHERE AgentUserName =
    '#session.AgentUserName#' </CFQUERY> </CFOUTPUT> } }

    nfitz Guest

  2. Similar Questions and Discussions

    1. Event for web page unload
      I have a flex application that needs to do a little clean up (acutally do a server post) when the user leaves the webpage. In java I could do it...
    2. Custom control fires event but ignores some code in the code behind file
      I do not quite understand the question. I will merely point out that most programming problems happen for a reason. Code works the way it is...
    3. UnLoad Event
      Does a page either dump all control rendering html to the response buffer prior to the UnLoad event? Basically I want everything sent to the...
    4. add Javascript code at the end of a SelectedIndexChanged event
      I have a webform that searches a database and displays the output in a datagrid. I would like to be able to call a javascript at the end of the...
    5. Raising an Event via Code
      Our web application has a user control on a web page to display hierarchical data and allow the user to "drill- down" the hierarchy tree. The user...
  3. #2

    Default Re: CF code in unload event

    Javascript and CF do not interact that way.

    If you view the source of your resulting HTML page, all that will appear is

    function jsUnload(){

    }
    }

    The CFML code is processed on the server before the final HTML content is sent
    to the browser. The <cfquery> is in no way tied to the Javascript function
    jsUnload().

    cf_menace Guest

  4. #3

    Default Re: CF code in unload event

    You could call a JS function on Unload which calls a CFM page which opens a new
    window which will run the appropriate code.
    I use that in the FRAMESET onUnload to log the user out of the system.
    <FRAMESET onUnload="logoff();">

    If you have CF 7 you can have an Application.cfc page in which you can setup
    onApplicationStart/End, onSessionStart/End, onRequestStart/End code - this may
    be what you're after??

    HTH

    Zoe


    zoeski80 Guest

  5. #4

    Default Re: CF code in unload event

    We only have 5, so I will try the frameset unload idea. I think that will work for us as well. Thanks much!!
    nfitz 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