IE work. Firefox Does not...help

T

Tmuldoon

Hi,

I have some Javascript that works on IE 6-7 but not Firefox(FF).

FF throws this error when clicked:

Hello,

Using Publisher 6.2 and Firefox 2.0

We have a customized Publisher template that creates some Javascript
that work fine in IE 6-7, but not FF.

FF returns this error:

Element referenced by ID/NAME in the global scope. Use W3C standard
document.getElementById() instead.
[Break on this error] undefined
(line 1)
oNug.all is not a function
[Break on this error] var e = oNug.all("disp");

How do I make it W3C compliant? Syntax help please!

Would I say var e=oNug.getElementById("disp"); ?

Why does it work with IE and not FF?

Thanks,

Tmuld
 
H

Holger Jeromin

Tmuldoon schrieb am 24.04.2008 17:08:
I have some Javascript that works on IE 6-7 but not Firefox(FF).

FF throws this error when clicked:

Hello,

Using Publisher 6.2 and Firefox 2.0

We have a customized Publisher template that creates some Javascript
that work fine in IE 6-7, but not FF.

We need your code for detailed analysis.
FF returns this error:

Element referenced by ID/NAME in the global scope. Use W3C standard
document.getElementById() instead.
[Break on this error] undefined
(line 1)
oNug.all is not a function
[Break on this error] var e = oNug.all("disp");

How do I make it W3C compliant? Syntax help please!

Would I say var e=oNug.getElementById("disp"); ?

Try this:
var e=document.getElementById("disp");
Why does it work with IE and not FF?

document.all is a MS invention. After that, the W3C has designed the
proper DOM functions, which were implemented by FF and MS.
 
T

Thomas 'PointedEars' Lahn

Tmuldoon said:
Using Publisher 6.2

Your apparently unsuitable development environment hardly matters here.
and Firefox 2.0

We have a customized Publisher template that creates some Javascript
that work fine in IE 6-7, but not FF.

FF returns this error:

Element referenced by ID/NAME in the global scope. Use W3C standard
document.getElementById() instead.
[Break on this error] undefined
(line 1)
oNug.all is not a function
[Break on this error] var e = oNug.all("disp");

How do I make it W3C compliant? Syntax help please!

Would I say var e=oNug.getElementById("disp"); ?

The error message indicates that `oNug' either does not refer to an object
that implements the HTMLDocument interface[1] or that Fx's Gecko is
rendering in Standards Compliance Mode. Therefore:

var e = document.getElementById("disp");
if (e)
{
// ...
}

or

var e = oNug.getElementsByName("disp");
if (e && (e = e[0]))
{
// ...
}

or, if "disp" is the name or ID of a form control within a `form' element:

var e = document.forms[zeroBasedNumberOrName].elements["disp"];

(You need to use e[zeroBasedNumber] if there is more than one control with
that name in the specified form.)

[1] http://www.w3.org/TR/DOM-Level-2-HTML/html.html
Why does it work with IE and not FF?

Because the `all' property/method is an MSHTML-proprietary feature that is
only sparsely supported by Fx, and then in Quirks Mode only. Avoid this
feature.


PointedEars
 
V

VK

FF returns this error:

Element referenced by ID/NAME in the global scope. Use W3C standard
document.getElementById() instead.

Well, the error description seems very clear. Don't use
document.all("disp") and use document.getElementById("disp") instead.
What is exactly not clear here?
 
T

Thomas 'PointedEars' Lahn

VK said:
Well, the error description seems very clear. Don't use
document.all("disp") and use document.getElementById("disp") instead.
What is exactly not clear here?

Only that the OP is not using `document.all' at the moment which causes a
standards-compliant solution to depend on the context in which the
proprietary `all' property was used before.


PointedEars
 
G

GTalbot

Well, the error description seems very clear. Don't use
document.all("disp") and use document.getElementById("disp") instead.
What is exactly not clear here?

No... not really. The OP was most likely using

var e = disp;

when in fact he should have been using

var e = document.getElementById("disp");

In IE, one can get script access to an id-ed element by simply using
its
id attribute value.
It's a very frequent error. And there are still many MSDN articles,
MSDN
code examples using the ID attribute to access elements.

Using Web Standards
Accessing Elements with the W3C DOM
http://developer.mozilla.org/en/doc...e_W3C_DOM#Accessing_Elements_with_the_W3C_DOM

Regards, Gérard
 
T

Thomas 'PointedEars' Lahn

GTalbot said:
No... not really. The OP was most likely using

var e = disp;

when in fact he should have been using

var e = document.getElementById("disp");

You are mistaken. First, there is no need to speculate about the OP's code
as the offending code is already in the error message, and Firefox's
behavior is very clear here. Second, see
<

PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top