473,587 Members | 2,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Firefox compatibility

I have a problem whit this script. It is compatible with IE but isn't with
Firefox.

The error are:
1) "e has no properties" at----- "if(e.pageX || e.pageY) {"
2) "document.getEl ementById()" at------>
"popText0.style .visibility="vi sible"
Help me please
Serena

//
// MOUSE position
//

var posX = 0;
var posY = 0;

function setPos () {
posX = 0;
posY = 0;

if (!e)
var e = window.event

if (e.pageX || e.pageY) {
posX = e.pageX
posY = e.pageY
}

else if (e.clientX || e.clientY) {
posX = e.clientX + document.body.s crollLeft
posY = e.clientY + document.body.s crollTop
}

return
}

document.onmous emove = setPos;
//
// MENU'
//

var popShow = new Array (false, false, false);

function popup (who) {
popText0.style. visibility = "hidden";
popText1.style. visibility = "hidden";
popText2.style. visibility = "hidden";

topbutton0.styl e.visibility = "visible";
topbutton1.styl e.visibility = "visible";
topbutton2.styl e.visibility = "visible";
if (!popShow[who]) {
if (( who == 0 ) || ( who == 1 ))
{
eval("popText"+ who+".style.lef t = posX + 10");
eval("popText"+ who+".style.top = -38");
}
else
{
eval("popText"+ who+".style.lef t = posX + 10");
eval("popText"+ who+".style.top = -38");
}
eval("popText"+ who+".style.vis ibility = \"visible\"" );

for(var count in popShow)
popShow[count] = false;

popShow[who] = true;
eval("topbutton "+who+".style.v isibility='hidd en'");
}
else
popShow[who] = false;

return;
}


Feb 4 '07 #1
2 1850
Serena wrote :
I have a problem whit this script. It is compatible with IE but isn't with
Firefox.

The error are:
1) "e has no properties" at----- "if(e.pageX || e.pageY) {"
2) "document.getEl ementById()" at------>
"popText0.style .visibility="vi sible"
Help me please
Serena

//
// MOUSE position
//

var posX = 0;
var posY = 0;

function setPos () {
posX = 0;
posY = 0;
posX and posY were set to 0 globally. Why do they need to be reset
again, and this time, locally?
>
if (!e)
var e = window.event
This will fail in Firefox and other DOM 2 event interface compliant
browsers. event is not a properties of the window.
You need to register an event listener on the targeted object.

DOM:element.add EventListener
http://developer.mozilla.org/en/docs/addEventListener
>
//
// MENU'
//

var popShow = new Array (false, false, false);

function popup (who) {
popText0.style. visibility = "hidden";
When you want to get access to a particular element, you must refer to
it via one of the DOM 2 methods and not just by its name attribute value
or just by its id attribute value.

This mistake is very frequent. See:

Accessing Elements with the W3C DOM
http://developer.mozilla.org/en/docs...th_the_W3C_DOM

Also

Comp.lang.javas cript FAQ
Why doesn't the global variable "divId" always refer to the element with
id="divId"?
http://jibbering.com/faq/#FAQ4_41

popText1.style. visibility = "hidden";
popText2.style. visibility = "hidden";

topbutton0.styl e.visibility = "visible";
topbutton1.styl e.visibility = "visible";
topbutton2.styl e.visibility = "visible";
if (!popShow[who]) {
if (( who == 0 ) || ( who == 1 ))
{
eval("popText"+ who+".style.lef t = posX + 10");
Using eval() is 99% of the time wrong.

Comp.lang.javas cript FAQ
When should I use eval?
http://jibbering.com/faq/#FAQ4_40

Also, here you are trying to position an element without defining its
unit creates a CSS parsing error.
CSS 1 and CSS 2.x specifications require that non-zero values must be
specified with a length unit; otherwise, the css declaration will be
ignored. Mozilla-based browsers, MSIE 6+, Opera 7+ and other W3C
standards-compliant browsers enforce such handling of parsing error.
CSS 1 Forward-compatible parsing
http://www.w3.org/TR/REC-CSS1#forwar...atible-parsing
CSS 2.1 Rules for handling parsing errors
http://www.w3.org/TR/CSS21/syndata.html#parsing-errors

Gérard
--
Using Web Standards in your Web Pages (Updated Dec. 2006)
http://developer.mozilla.org/en/docs...your_Web_Pages
Feb 4 '07 #2
Hi,

Gérard Talbot wrote:
Serena wrote :
>I have a problem whit this script. It is compatible with IE but isn't
with Firefox.

The error are:
1) "e has no properties" at----- "if(e.pageX || e.pageY) {"
2) "document.getEl ementById()" at------>
"popText0.styl e.visibility="v isible"
Help me please
Serena

//
// MOUSE position
//

var posX = 0;
var posY = 0;

function setPos () {
posX = 0;
posY = 0;

posX and posY were set to 0 globally. Why do they need to be reset
again, and this time, locally?
Because they are global. Further in the function they are set to a
value. Since we don't know when (and how often) the function will be
called, resetting them to 0 might be necessary.

The code could be much more modular, object-oriented, and that would
remove the need for global variable.
> if (!e)
var e = window.event

This will fail in Firefox and other DOM 2 event interface compliant
browsers. event is not a properties of the window.
You need to register an event listener on the targeted object.
That's probably what she did somewhere in the code which she doesn't
show us. For example, if you have

document.onload = setPos;

then you should declare the function like this:

function setPos( e )
{
...
}

Mozilla-based browsers pass the event details to the function when the
event handler is called. I always found this way of doing confusing and
for once prefer the IE way.

Maybe a better way is to go the other way round:

function setPos( e )
{
if ( window.event )
{
e = window.event;
}

if ( !e )
{
throw "Unknow platform";
}
}

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Feb 4 '07 #3

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

Similar topics

18
8077
by: Niels | last post by:
Hi group, I have some problems with clearing floated divs. My usual method works fine in Konqueror, but not in Firefox. Here's an example: <html><body> <div id='left' style='float:left; border:1px solid red;'>Floated left</div> <div id='right' style='float:right; border:1px solid blue;'>Floated right</div>
15
2183
by: 50295 | last post by:
Hi everyone, This one is better experienced than explained, so I'm including a code sample below. Please and save (as an html file) and view with NN or Firefox (or maybe even Mozilla), and then view. When loaded: (1.) Place the mouse over "Top Menu" item. (The menu opens) (2.) Move to any of the sub-menu items. (3.) Click on the left or...
36
3544
by: Simon Wigzell | last post by:
I have the following in my webpage: <body onresize=CenterIt(); onMouseMove=mouseCheck(event);> CenterIt and mouseCheck are my own javascript functions. Works fine for IE and Opera, doesn't even go into the function for Firefox or Netscape. Is there a different way to assign functions to events that will be understood by "all" browsers?...
4
2019
by: fcurvat | last post by:
Hello, I've got a little problem with <script></script> under firefox 1.0.7 If the script is not placed in the body tag, it isn't automaticaly executed, but it is under Internet Explorer. Here's an example of what i do. Do anybody have any idea?
5
1761
by: BJ | last post by:
Hi, I add label and text box fields dynamically in code using C# and ASP.NET. I set the width of the label using: Label label = new Label(); label.Width = 20; label.Text = "Test"; panel.Controls.Add(label);
45
4699
by: Pat | last post by:
its seems asp.net validation doesn't fire when using FireFox? Tested a page and it doesn't fire. It seems the javascript doesn't fire Any ideas?
1
1459
by: newspost2000 | last post by:
If anyone could help me out here. I am the webmaster of the following corporate website: http://www.otpp.com/. When I load this page in IE or Netscape for PC the postion of all of the elements on the homepage is generally the same between these two browsers. When you navigate into the site the Teachers' logo is always in the same position...
3
1483
by: VK | last post by:
A minor Firefox update was released (now 1.5.0.1) Full list of fixes can be found here: <http://www.mozilla.com/firefox/releases/1.5.0.1.html> Unfortunately the same update bans Venkman for Firefox 1.5 The only one half-official version was at <http://www.mozilla.org/projects/venkman/> Right after update it was announced as...
10
3023
by: Paul Gorodyansky | last post by:
Hi, Ran into the problem today - in INPUT field Firefox executes clean-yp of the content if a user presses Esc, _before_ control goes to the code via onkeydown - and search showed that it's a known issue: https://bugzilla.mozilla.org/show_bug.cgi?id=236628 The bug is closed due to the inactivity (I've just written to the Submiter...
5
1670
by: Charlie | last post by:
Hi: I have some Custom server controls (validated textboxes) in a panel on a form. In Firefox, it looks all hosed up. Also, pictures show place holders while loading. What are my options for getting things to look right in firefox? Thanks, Charlie
0
7915
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...
0
7843
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...
0
8205
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7967
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...
0
6619
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...
0
5392
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...
0
3840
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...
1
2347
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
0
1185
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...

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.