none
event.clientY undefined in internet explorer 11 latest version RRS feed

  • Question

  • Hello Guys,

      I am using the below javascript code for refresh/close the browser, but i am getting undefined error in var y, We have to capture the refresh/Close event for javascript code. If you have any ideas/solutions ?

     
    <script type='text/javascript'>
         //Maps an event to the window closing event
         window.onbeforeunload = function(e) {
             var y = event.clientY || event.screenY || event.pageY;
             if (y < 0) {
                closeEvent = true;
               }
         };
     </script>

    Wednesday, September 2, 2015 9:33 AM

All replies

  • Hi Team,

    event.clientY undefined in internet explorer 11 latest version

      I am using the below code, but i am getting undefined error, I need to differentiate (refresh/close) event. Kindly provide any alternate solution or event for below issue.

    <script type='text/javascript'>
       
    //Maps an event to the window closing event
        window
    .onbeforeunload = function(e) {
           
    var y = event.clientY || event.screenY || event.pageY;
            if (y < 0) {
               closeEvent
    = true;
              }
       
    };
    </script>

    Wednesday, September 2, 2015 5:49 AM
  • Hi,

    event is a javascript keyword and is automatically passed as a parameter to an event handler function, but not to an inline event handler... your function should refer to the passed e event, not the event keyword.

    it looks like you are trying to detect if the current window was closed from the IE close button [X], by detecting a negative pageX or pageY value. This is no longer supported in IE for security reasons. Without your full page source it is uncertain the purpose that you are trying to achieve.

    Post questions about html, css and scripting to http://stackoverflow.com. If possible include with your questions, a link to your website or a mashup (jsfiddle) that shows your issue, and the full error messages from the Dev tool console.

    Tools>Internet Options>Advanced tab, check "Record console error messages".

    To invoke the dev tool debugger... f12>Debug tab, select "Break on all errors" from the dropdown... and or place breakpoints on the script lines that you are already interested in.

    Return to the browser without closing the dev tool and do you testing. The dev tool will break on exceptions and break points. Use the local varibles and call stack panels in the dev tool to troubleshoot your coding.

    Regards.

    Questions regarding Internet Explorer 8, 9 and 10 and Internet Explorer 11 for the IT Pro Audience. Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions. If you are a consumer looking for answers or to raise a question, it's highly recommended you head on over to http://answers.microsoft.com/en-us


    Rob^_^

    • Proposed as answer by jim-xu Friday, September 11, 2015 5:09 AM
    • Unproposed as answer by jim-xu Friday, September 11, 2015 5:09 AM
    Thursday, September 3, 2015 12:11 AM
  • Hi Rob,

     Acutally i am using master & content page, the below code used in my child page. I am always getting undefined for the below properties and also i compared all properties for refresh/close.I couldn't differentiate any properties value.  IE11 browser behaviour refresh & close are same ?

    document.body.onbeforeunload = pageClose;

    function pageClose() {

    var y = event.clientY || event.screenY || event.pageY || event.pageX;
              if (y < 0) {
                 closeEvent = true;
                }

    }

    Thursday, September 3, 2015 7:48 AM
  • Hi,

    Post questions about html, css and scripting for website developers to http://stackoverflow.com. Copy and paste your page source (View>Source menu from IE) with your question. (not your .net source).

    You may get a .net specific answer in an MSDN .net support forum.

    pageX no longer returns negative values when an IE tab or window is closed for security reasons. ShowModalDialog is being depreciated and you should use a popup div (say jquery.dialog plugin) instead. You should already be using addEventListener instead of inline and anonymous event handlers, and specify an event argument in the function.

    Questions regarding Internet Explorer 8, 9 and 10 and Internet Explorer 11 for the IT Pro Audience. Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions. If you are a consumer looking for answers or to raise a question, it's highly recommended you head on over to http://answers.microsoft.com/en-us


    Rob^_^

    Thursday, September 3, 2015 8:27 AM
  • HI I tried the performance.navigation.type

    Close - return 1 sometimes return 0 also

    Refresh - return 1

    this property is not working properly

    Thursday, September 3, 2015 10:44 AM