Remya
Remya

Reputation: 103

javascript format for mozilla

what is the equallent of window.event.clientX for mozilla in javascript? This is my code, function called in body-> onbeforeunload="return CloseOrNotClose(event);"

This is fine for ie but not working in mozilla.

function CloseOrNotClose(event) {

var ie = document.all;
if (ie) {
           if ((window.event.clientX < 0) || (window.event.clientY < 0)) {
                    return "Your Information related to this exam will be lost and you will have to reappear for it, \nDo you want to continue?";
             }
}
else {
    if ((event.clientX < 0) || (event.clientY < 0)) 
    return "Your Information related to this exam will be lost and you will have to reappear for it, \nDo you want to continue?";
}

}

Upvotes: 0

Views: 308

Answers (2)

sultan
sultan

Reputation: 6058

Can you show your entire function you've been using?

This works for me:

function getXY(e)
{
  var e=(!e) ? window.event : e;
  var X = 0;
  var Y = 0;

  if(e.pageX)
  {
    X = e.pageX + window.pageXOffset;
    Y = e.pageY + window.pageYOffset;
  }

Upvotes: 0

RobertO
RobertO

Reputation: 2663

Internet Explorer has window.event.clientX

Mozilla has:

function show_coords(event)
{
  var x = event.clientX;
  var y = event.clientY;
  alert("X coords: " + x + ", Y coords: " + y);
}

edit1:

function called in body-> onbeforeunload="return CloseOrNotClose(event);"

I think it only works for Mozilla as window.onbeforeunload = CloseOrNotClose;

edit2:

Note that in Firefox 4 and later the returned string is not displayed to the user.

See https://developer.mozilla.org/en/DOM/window.onbeforeunload

Upvotes: 2

Related Questions