Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   IE work. Firefox Does not...help (http://www.velocityreviews.com/forums/t935618-ie-work-firefox-does-not-help.html)

Tmuldoon 04-24-2008 03:08 PM

IE work. Firefox Does not...help
 
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

Holger Jeromin 04-24-2008 03:15 PM

Re: IE work. Firefox Does not...help
 
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.

--
Mit freundlichen Grüßen
Holger Jeromin

Thomas 'PointedEars' Lahn 04-28-2008 11:11 AM

Re: IE work. Firefox Does not...help
 
Tmuldoon wrote:
> 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
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16

VK 04-28-2008 02:20 PM

Re: IE work. Firefox Does not...help
 
On Apr 24, 7:08 pm, Tmuldoon <tmuld...@spliced.com> wrote:
> 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?




Thomas 'PointedEars' Lahn 04-28-2008 02:48 PM

Re: IE work. Firefox Does not...help
 
VK wrote:
> On Apr 24, 7:08 pm, Tmuldoon <tmuld...@spliced.com> wrote:
>> 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?


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
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>

GTalbot 04-29-2008 05:19 AM

Re: IE work. Firefox Does not...help
 
On 28 avr, 10:20, VK <schools_r...@yahoo.com> wrote:

> > 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?


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/docs...th_the_W3C_DOM

Regards, Gérard

Thomas 'PointedEars' Lahn 04-29-2008 05:32 PM

Re: IE work. Firefox Does not...help
 
GTalbot wrote:
> On 28 avr, 10:20, VK <schools_r...@yahoo.com> wrote:
>>> 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?

>
> 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
<news:4815E3B4.4010804@PointedEars.de>.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


All times are GMT. The time now is 11:44 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.