473,909 Members | 5,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Events in Mozilla and firefox?

The following works fine in IE -> what am I missing to make it work in
Firefox - an example would be great?

I can't figure it out :-)
------------------------------------------------
<body>

<script language="javas cript">
var IE = document.all?tr ue:false;
if (!IE) document.captur eEvents(event.M OUSEMOVE);
document.onmous emove = getMouseXY;

var x,y,tmpcords;

function getMouseXY(e) {
if(IE){
x = event.clientX + document.body.s crollLeft;
y = event.clientY + document.body.s crollTop;
} else {
x = e.pageX;
y = e.pageY;
}

//Check if length is above 1200
if(document.all ._clientEyeText box.value.lengt h > 1200){
return calc();
document.all._c lientEyeTextbox .value = '';
} else {
document.all._c lientEyeTextbox .value =
document.all._c lientEyeTextbox .value + x + ',' + y + ',';
//document.all.a. value = document.all.a. value + x + ',' + y + ',';
}
}
</script>

</body>
------------------------------------------------

Best regards

Michael Christensen

Oct 24 '05 #1
3 5707
Michael Christensen said the following on 10/24/2005 2:08 PM:
The following works fine in IE -> what am I missing to make it work in
Firefox - an example would be great?

I can't figure it out :-)


Try Tools>Javascrip t Console
Stop assuming that the existence of document.all means you are dealing
with IE - it doesn't.
Stop thinking you need to know what browser you are dealing with - you
don't.
Start feature detecting.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Oct 24 '05 #2
Michael Christensen wrote:
The following works fine in IE -> what am I missing to make it work in
Firefox - an example would be great?

I can't figure it out :-)
------------------------------------------------
<body>

<script language="javas cript">
The language attribute is depreciated, type is required:

<script type="text/javascript">

var IE = document.all?tr ue:false;
When posting code, indent using 2 or 4 spaces, not tabs. It helps to
stop wrapping which nearly always introduces errors. Manually wrap code
at about 70 characters (same reason).

As Randy said, browser detection based on whether or not certain
functions are supported is flawed. Simply don't do it.

if (!IE) document.captur eEvents(event.M OUSEMOVE);
For some reading about how/when to use captureEvents:

<URL:http://www.quirksmode. org/js/events_order.ht ml>
<URL:http://www.quirksmode. org/js/events_netscape 4.html>

Remove the -- if (!IE)... -- line...

document.onmous emove = getMouseXY;
And add this one here...

if (document.captu reEvents){
document.captur eEvents(Event.M OUSEMOVE);
}

var x,y,tmpcords;
It's probable that these globals aren't needed. If the issue is
returning multiple values from a function, you can do that by putting
them into an array and return that.


function getMouseXY(e) {
if(IE){
x = event.clientX + document.body.s crollLeft;
y = event.clientY + document.body.s crollTop;
} else {
x = e.pageX;
y = e.pageY;
}
Once you remove browser sniffing, the above becomes:

function getMouseXY(e)
{
var e = e || window.event;
if (e.pageX || e.pageY){
x = e.pageX;
y = e.pageY;
} else if (e.clientX || e.clientY) {
x = event.clientX + document.body.s crollLeft;
y = event.clientY + document.body.s crollTop;
}

<URL:http://www.quirksmode. org/js/events_properti es.html>


//Check if length is above 1200
if(document.all ._clientEyeText box.value.lengt h > 1200){
What is _clientEyeTextb ox? If it's the name of a form control, then the
best way to access it is to get a reference then use that ('formName' is
the name of the form):

var textBox = document.forms. formName._clien tEyeTextbox;
if (1200 < textBox.value){
If _clientEyeTextB ox is the id of the control, then it's invalid since
id attributes must start with a letter (it's OK for a name to start with
an underscore, but certain valid name characters will cause problems in
places depending on how you access the control). Read the HTML spec on
name and id attributes.

return calc();
The function will end here if the if statement returned true.
document.all._c lientEyeTextbox .value = '';
This line will not be reached, but if it is was it should be:

textBox.value = '';
} else {
document.all._c lientEyeTextbox .value =
document.all._c lientEyeTextbox .value + x + ',' + y + ',';
textBox.value += x + ',' + y + ',';

Since you seem to be storing x and y in the text box, they need not be
global variables. And if the text box is a device for passing the
values to some other function, you could use:

return [x, y];

to return the values in an array - but my assumption may be a wrong.

//document.all.a. value = document.all.a. value + x + ',' + y + ',';
}
}
</script>

</body>


All the above is untested - if you provide some working code with
associated HTML (minimal working example) then better help can be provided.

--
Rob
Oct 24 '05 #3
VK
> Events in Mozilla and firefox?

A bit offtopic but important to mention:
The question sounds similar to: "Difference between mammals and cows".
Any modern graphical browser is Mozilla meaning it has "Mozilla" in its
USER_AGENT string.

Oct 25 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
3348
by: Thomas | last post by:
Hi, I'm having a problem with the dynamically created inputfields in Internet Explorer. The situation is the following: - I have a dynamically created table with a textbox in each Cell. - It is possible to Add and Delete rows - Some cells have special attributes (readonly and events) Here's a snippet of the code:
20
12912
by: David | last post by:
I have a one-line script to add an onunload event handler to the body of the document. The script is as follows: document.getElementsByTagName("BODY").onunload=function s() {alert("s")} Now obviously, I put the alert("s") part in for debugging purposes, just to make sure the error wasn't in any code I was going to be running. This line works just fine in IE6 but in Firefox it doesn't. However, if I replace that line with the...
3
7908
by: Praveen | last post by:
In IE a table element will receive focus when you either tab into it or when you click anywhere within the table. Mainly it fires the onfocus event. This doesn't happen in Mozilla (Firefox and Netscape). Is there any setting or anyother way to force the table element to fire the onfocus and onblur events? Thanks
9
1672
by: Lachlan Hunt | last post by:
Hi, I've written some javascript to implement DOM 2 Events in IE (addEventListener, removeEventListener, etc) and I would like to know which browsers it works in. I've tested it in Firefox 1.0.6, Deer Park Alpha 2, Opera 8.02 and IE6 and IE7 Beta 1, all on WinXP SP2. Could some of you please take a look at the test pages in any browser you have available to you, and let me know if it works or if you encounter any problems? If...
2
3232
by: Arnaud Diederen | last post by:
Hello, I cannot succeed in getting any key event on a div that's been set invisible by the style's MozOpacity property under firefox. I'm using this method so that I can capture the mouse events. Unfortunately, it appears to do so only with mouse events, not key events. Is there a better solution than the following? :
5
4392
by: Richard Maher | last post by:
Hi, Here I mean "User" in the Programmer or Javascript sense. I merely wish to programmatically trigger an Event. It would be absolutely fantastic if there was a (Form level?) ONUSEREVENT() and a setEvent() function but, in the absence of this, is it not possible to use DOM to change an object's properties resulting in a state-change event? I have tried with ONCHANGE() and that only seems to work if the "interactive" user changes the...
7
2350
by: mavigozler | last post by:
IE7 does not appear to set an event on contained text inside SPAN elements whose 'onclick', 'onmouseover', and 'onmouseout' events, defying the HTML recommendation. Firefox appears to conform. Is that so?
2
4247
by: Lazarus | last post by:
Hi, I have a canvas that reacts to mousedown and mousemove. Once I click the canvas I want to track the cursor wherever it goes, including outside the browser. Setting window.onmousemove only gives events inside the browser of course. I tried window.captureEvents which works on Safari but FireFox says it's deprecated. Mozilla's docs say to use window.addEventListener but the behavior is the same: in Safari I can drag outside the window and...
0
10037
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
9879
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,...
1
11052
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10540
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
8099
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
5938
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...
1
4776
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
2
4336
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3359
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.