473,749 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

window.event.x

41 New Member
i m wrinting javascript. on button click i am calling a javascript function that returns (x,y) coordinate of point where i clicked.
i used
window.event.x and window.event.y

it works fine in IE but not in mozila ..why so
any solution
thnx
Oct 14 '08 #1
5 8530
rnd me
427 Recognized Expert Contributor
#1- there is no window.event in firefox.
#2- there is no x property of an event object. try screenX instead.
Oct 14 '08 #2
zaphod42
55 New Member
Expand|Select|Wrap|Line Numbers
  1. mouseX=function(evt){
  2. return(evt?(evt.pageX?evt.pageX:evt.clientX):(window.event.pageX?window.event.pageX:window.event.clientX))+(document.documentElement.scrollLeft?document.documentElement.scrollLeft:document.body.scrollLeft)
  3. }
  4. mouseY=function(evt){
  5. return(evt?(evt.pageY?evt.pageY:evt.clientY):(window.event.pageY?window.event.pageY:window.event.clientY))+(document.documentElement.scrollTop?document.documentElement.scrollTop:document.body.scrollTop)
  6. }
Oct 16 '08 #3
Rsmastermind
93 New Member
#1- there is no window.event in firefox.
#2- there is no x property of an event object. try screenX instead.
Sorry to say but there is window.event in the firefox I had done and executed the code.The code written above by zaphod42 will work fine instead of the browser's behaviour.

The second solution provided by you is ok.
Oct 16 '08 #4
rnd me
427 Recognized Expert Contributor
Sorry to say but there is window.event in the firefox I had done and executed the code.The code written above by zaphod42 will work fine instead of the browser's behaviour.
I can personally assure you there is no window.event in firefox (unless you create one).

yes the code does work fine. thats because the firefox part doesn't use window.event but the intrinsic event argument, in this case named evt.
i know it's confusing, so lets break it down:


in the code:
Expand|Select|Wrap|Line Numbers
  1.  mouseY=function(evt){
  2.  return(evt?(evt.pageY?evt.pageY:evt.clientY):(wind  ow.event
  3.  
it asks (evt?)
if yes ( an event object was passed to the function, as in firefox), it returns evt.pageY or evt.clientY.

if (evt?) results in no, it means no argument was passed, as in IE.
it then returns window.event.pa geY or window.event.cl ientY

so to sum: ie uses the window.event part, and firefox uses the argument evt part.

i hope this helps shed some light on the two confusing event models.
Oct 16 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
This similar code will be a little easier to understand.
Oct 16 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
16600
by: Barry Svee | last post by:
I'm struggling with the JavaScript blur event. I have an activex control that I need to interact with when a window loses focus, namely to instruct it to give up control of a barcode scanner so that the application being brought foreward can take control. It has been my observation that when I set the window.onblur function, the window will gain focus and then immediately lose focus (blur) to the first field, button, or whatever that is...
6
4577
by: Brian | last post by:
Hi everyone, I'm writing a function (in javascript) that needs to do one thing if the page has not loaded, and another (different) thing if the page has already loaded. I'm looking for a way to tell if the window.onload event has already fired. I cannot edit the onload event handler itself, and my function can only exist in an external js file, sourced from the document's head section. Any ideas?
10
9801
by: Tom Szabo | last post by:
Is there an event when that triggers when the window is closing.... I am talking about when the user clicks on the cross on the right top corner of the window!!!
3
27192
by: Søren M. Olesen | last post by:
Hi In IE there seem to be a global variable window.event, holding the current event....however this dowsn't work in FireFox... is there a similar way to get the current event?? TIA Søren
19
31067
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). The problem is that after the reload, it brings you right to the top of the page. When I click 'refresh" on the original page, it brings me back to the original viewing position. Is there a way to duplicate this in from the popup window. Also,...
14
1488
by: Thomas Mlynarczyk | last post by:
Hi, I have a JavaScript application which opens a second window. Which is the best way to detect over which (if any) of the two windows the mouse is? First I thought document.onmouseout and document.onmouseover (for both windows) would be the way to do it, but some browsers (like Firefox) seem to fire these even when the mouse passes within the document (like from the "empty body background" to a div), and anyway, any child elements of...
6
1578
by: Donius | last post by:
Is there a simple and clean way to get the window object that contains an element that is passed into a function? I want to throw some alerts / confirms, but don't want to switch away from whatever window they're currently looking at. I can step up by parentNode until the nodeType equals 9, which means the document element, and then step up one more...does that ensure a window object? Or i could step up until the node had no...
1
11581
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at http://weblogs.asp.net/asmith/archive/2003/09/15/27684.aspx but it was far more complex then I needed. (I got lost trying to figure it all out). Therefore, here goes my simple "web dialog box with parent event handler fireing" solution. ...
9
6840
by: mike | last post by:
I have this script executing <script> function mike_test(event) { x = window.event.clientX; alert(x); } </script> <iframe src="blank.html" id="my_iframe1"> </iframe>
6
63107
by: Luke Matuszewski | last post by:
As in topic... has anyone used it ? I tried to use it but i guess i failed... here is a code: <html> <head> <title></title> <script type="text/javascript"> function closedWin() { confirm("close ?");
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4709
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.