AttachEvent - permission denied ?

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

    AttachEvent - permission denied ?

    Using asp.net 2003

    When I use

    document.attach Event("onmousem ove", resetTimer);

    The first time into a page, it works fine, but the 2nd time the page is
    loaded (not postback) it gives a permission denied error.. any ideas why ?

    Thanks
    -Adrian


  • Martin Honnen

    #2
    Re: AttachEvent - permission denied ?



    Adrian Parker wrote:
    [color=blue]
    > Using asp.net 2003
    >
    > When I use
    >
    > document.attach Event("onmousem ove", resetTimer);
    >
    > The first time into a page, it works fine, but the 2nd time the page is
    > loaded (not postback) it gives a permission denied error.. any ideas why ?[/color]

    You usually get that error message when your script tries to access a
    document in another frame or window it doesn't have access to due to the
    same origin policy only allowing access to window/frames with documents
    being loaded from the same host/domain.
    Are you using any frames or popup windows, does resetTimer try to access
    data in another window/frame?


    --

    Martin Honnen

    Comment

    • Adrian Parker

      #3
      Re: AttachEvent - permission denied ?

      > You usually get that error message when your script tries to access a[color=blue]
      > document in another frame or window it doesn't have access to due to the
      > same origin policy only allowing access to window/frames with documents
      > being loaded from the same host/domain.
      > Are you using any frames or popup windows, does resetTimer try to access
      > data in another window/frame?[/color]

      I am using frames, but the pages in the other 2 frames do not have this code
      in them.

      Here's the code.. first time in is ok, it's the 2nd time the page is loaded
      that has the problem with the attachevent.

      <script>

      var SRV_IDLE_TIME = 1200000;
      var srv_timerID = -1;
      var CLI_IDLE_TIME = 900000;
      var cli_timerID = -1;

      // On page load, start times and set focus
      function onLoading() {
      startTimer();
      placeFocus();
      }

      // Clear timers when page unloaded
      function onUnloading() {
      if (cli_timerID != -1) {
      clearTimeout(cl i_timerID);
      }
      if (srv_timerID != -1) {
      clearTimeout(sr v_timerID);
      }
      }

      // Start Timers
      function startTimer() {
      cli_timerID = window.setTimeo ut("timeOut()", CLI_IDLE_TIME);
      srv_timerID = window.setTimeo ut("timeOut()", SRV_IDLE_TIME);
      }

      // Restart the client side inactivity timer
      function resetTimer() {
      if (cli_timerID != -1) {
      clearTimeout(cl i_timerID);
      cli_timerID = window.setTimeo ut("timeOut()", CLI_IDLE_TIME);
      }
      }

      // Client side inactivity timeout
      function timeOut() {
      if (cli_timerID != -1) {
      clearTimeout(cl i_timerID);
      }
      cli_timerID = -1;
      if (srv_timerID != -1) {
      clearTimeout(sr v_timerID);
      }
      srv_timerID = -1;
      location.href=' logout.aspx';
      }

      function placeFocus() {
      if( Form1.elements[0]!=null) {
      var i;
      var max = Form1.length;
      for( i = 0; i < max; i++ ) {
      if( Form1.elements[ i ].type != "hidden" &&
      !Form1.elements[ i ].disabled &&
      !Form1.elements[ i ].readOnly &&
      (Form1.elements[ i ].type == "text" ||
      Form1.elements[ i ].type == "textarea") ) {
      Form1.elements[ i ].focus();
      break;
      }
      }
      }
      }

      document.attach Event("onmousem ove", resetTimer);
      document.attach Event("onclick" , resetTimer);
      document.attach Event("onkeydow n", resetTimer);

      </script>

      <body onload="onLoadi ng();" onunload="onUnl oading();" .....etc




      Comment

      • Martin Honnen

        #4
        Re: AttachEvent - permission denied ?



        Adrian Parker wrote:

        [color=blue]
        > I am using frames, but the pages in the other 2 frames do not have this code
        > in them.
        >
        > Here's the code.. first time in is ok, it's the 2nd time the page is loaded
        > that has the problem with the attachevent.[/color]

        Odd, there is indeed nothing in the code that tries to access another
        frame and could therefore cause a permission denied. I don't know why
        you get the error.


        --

        Martin Honnen

        Comment

        • Jim Ley

          #5
          Re: AttachEvent - permission denied ?

          On Sat, 18 Sep 2004 17:07:05 +0200, Martin Honnen <mahotrash@yaho o.de>
          wrote:
          [color=blue]
          >Adrian Parker wrote:[color=green]
          >> I am using frames, but the pages in the other 2 frames do not have this code
          >> in them.
          >>
          >> Here's the code.. first time in is ok, it's the 2nd time the page is loaded
          >> that has the problem with the attachevent.[/color]
          >
          >Odd, there is indeed nothing in the code that tries to access another
          >frame and could therefore cause a permission denied. I don't know why
          >you get the error.[/color]

          I've seen this sort of thing recently onload, never seen it with my
          code so never looked into it - I think it may be related to IE doesn't
          fully recompile the code on an F5 refresh if the docs haven't changed.

          It'd be good to reproduce a test-case and finally look at this I think
          - can the OP get the files on line - preferably reduced to the minimum
          that exhibits the problem.

          Jim.

          Comment

          • Adrian Parker

            #6
            Re: AttachEvent - permission denied ?

            > I've seen this sort of thing recently onload, never seen it with my[color=blue]
            > code so never looked into it - I think it may be related to IE doesn't
            > fully recompile the code on an F5 refresh if the docs haven't changed.
            >
            > It'd be good to reproduce a test-case and finally look at this I think
            > - can the OP get the files on line - preferably reduced to the minimum
            > that exhibits the problem.
            >
            > Jim.[/color]

            Hmm.. this is odd.. same code running on a non-dev win2k box runs fine.
            my dev box is running win2k sp2.

            I'll try to mock up a single page with the script on it.

            -Adrian


            Comment

            • Adrian Parker

              #7
              Re: AttachEvent - permission denied ?

              Finally found the problem. At server side I was doing a response.redire ct
              which doesn't work properly.. if I change it to use server.transfer it works
              fine.


              Comment

              Working...