473,466 Members | 1,391 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Event not supported in Mozilla

41 New Member
I have following code to generate a transpert pop up for onchange event of drop down

Expand|Select|Wrap|Line Numbers
  1. if (xmlHttp.readyState==4)
  2.     /* get the mouse left position */
  3.     var x = event.clientX + document.body.scrollTop + 360; // LINE 1
  4.     /* get the mouse top position */
  5.     var y = event.clientY + document.body.scrollTop + 330; // LINE 2
  6.     /* display the pop-up */
  7.  
  8.     /* set the pop-up's left */
  9.     Popup.style.left = x;
  10.     /* set the pop-up's top */
  11.     Popup.style.top = y;
  12.     Popup.style.display="block"; 
  13.     document.getElementById("Popup").innerHTML=xmlHttp.responseText;
Above code works fine for IE but in MOzilla it gives error "EVENT is not defined"
Please note: LINE 1 and LINE 2 are used to adjust position of window. If I remove it code works fine for all browsers but does not have a position that I want.

Please help
Jan 12 '10 #1
8 2294
Dormilich
8,658 Recognized Expert Moderator Expert
correct, Mozilla does not have a global event attribute (window.event) like IE. you need a parameter in the function call (which is auto-populated by JavaScript) to access the event object.

Event handlers may be attached to various elements in the DOM. When an event occurs, an event object is dynamically created, and passed sequentially to the event listeners that are allowed to handle the event. The DOM Event interface is then accessible within the handler function, via the event object passed as the first (and the only) argument.
see also clientX and event @ MDC
Jan 12 '10 #2
SwapnilD
41 New Member
How can I do that. Can you please give an example?
Jan 12 '10 #3
Dormilich
8,658 Recognized Expert Moderator Expert
check out the given links, they contain plenty of examples.
Jan 12 '10 #4
SwapnilD
41 New Member
Per your suggestion I have changed the function as below

"function stateChanged2(event) " // I have passed Event attribute

It works fine for Mozilla but does not work for IE i.e. Exactly the revere case of above.

How can I deal with this.

I really appreciate your prompt responses.

Thanks.
Jan 12 '10 #5
Dormilich
8,658 Recognized Expert Moderator Expert
I’m not familiar with IE issues, but you shouldn’t name the variable "event" (same goes for any reserved keyword). I guess that IE does not pass this parameter, so it overwrites the global attribute event due to the parameter having the same name.

but of course you can test for either version:
Expand|Select|Wrap|Line Numbers
  1. function handle(evt)
  2. {
  3.     var evt = evt || window.event;
  4.     evt.clientX = …
  5. }
How can I deal with this.
discard IE ;)
Jan 12 '10 #6
SwapnilD
41 New Member
Thanks buddy...I have modified the code as below and it is working fine for all the browsers (IE, FF, CHROME and SAFARI)

Expand|Select|Wrap|Line Numbers
  1. function stateChanged2(evt) 
  2. if (xmlHttp.readyState==4)
  3.     var evt = window.event || evt; 
  4.  
You are really GREAAATTTTTT......!
Jan 12 '10 #7
Dormilich
8,658 Recognized Expert Moderator Expert
please don’t exaggerate, I’m not that great, this is just common cross-browser knowledge.
Jan 12 '10 #8
RedSon
5,000 Recognized Expert Expert
We <3 Dormi
Jan 12 '10 #9

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

Similar topics

10
by: tony kulik | last post by:
This code works fine in ie and opera but not at all in Mozilla. Anybody got a clue as to how to get it right? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <script...
4
by: Pai | last post by:
hello there, I am trying to rersize the window it works find in IE but doea not work with mozilla window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello');...
4
by: Robert | last post by:
Hi, which DOM version (level) should I learn? I've seen that there is a DOM level 3, but is there any support for it already? -- Rob
2
by: D. Alvarado | last post by:
Hi, I'm having some trouble with the "onBlur" event in the BODY tag. Ideally, what I want to happen is that when someone leaves window A, window A executes a command. I had put <body...
3
by: Lachlan Hunt | last post by:
Hi, I've been looking up lots of documentation and trying to work out a cross-platform method of capturing a keyboard event and working out which key was pressed. From what I can find, there...
2
by: mark4asp | last post by:
Why does this not work in Mozilla ? <http://homepage.ntlworld.com/mark.pawelek/code/animals.html> The optHabitat_change() event does not fire. What am I doing wrong here? PS: It should...
6
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() {...
15
by: RobG | last post by:
When using createEvent, an eventType parameter must be provided as an argument. This can be one of those specified in DOM 2 or 3 Events, or it might be a proprietary eventType. My problem is...
6
by: Gregor Kofler | last post by:
I'm trying to "detect" a keydown event in a DIV. The idea have a keydown listener attached to document and forward the event to the div. (I've searched the web, but it was impossible to handle...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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,...
0
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...
0
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...
0
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 ...

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.