Problem with getting the doc

C

Clemenza

Hello,

I use the following javascript code, which works well in IE and Opera,
but doesn't work with Firefox and Mozilla.

I always get an error "doc is not defined" when try to run code
eval(doc + layerName + sty + ".left = " + (eval(FromLeft) + 15))

Before I setup the doc variable as this:
var ie = document.all ? 1 : 0
var ns = document.layers ? 1 : 0
if(ns){doc = "document."; sty = ""}
if(ie){doc = "document.all."; sty = ".style"}

Any idea?

Thanks!
 
D

David Dorward

Clemenza said:
I use the following javascript code, which works well in IE and Opera,
but doesn't work with Firefox and Mozilla.
var ie = document.all ? 1 : 0

Internet Explorer stuff that Opera and Mozilla support - but Mozilla only
very recently introduced support and returns false to document.all to
discourage its use. You only need this if you need to support versions of
IE older then 6.
var ns = document.layers ? 1 : 0

Netscape 4 specific code. Support dropped after the 4.x series.

See http://www.mozilla.org/docs/web-developer/upgrade_2.html
 
R

Randy Webb

Clemenza said:
Hello,

I use the following javascript code, which works well in IE and Opera,
but doesn't work with Firefox and Mozilla.

It doesn't "work well" in IE or Opera, you just think it does.
I always get an error "doc is not defined" when try to run code
eval(doc + layerName + sty + ".left = " + (eval(FromLeft) + 15))

Why are you using eval when you don't need it?
Had you bothered reading the group FAQ before posting you would have,
undoubtedly, found this section:

http://jibbering.com/faq/#FAQ4_40

Before I setup the doc variable as this:
var ie = document.all ? 1 : 0
var ns = document.layers ? 1 : 0
if(ns){doc = "document."; sty = ""}
if(ie){doc = "document.all."; sty = ".style"}

Geeeez....
Ummm, you should read that FAQ, especially section:

http://jibbering.com/faq/#FAQ4_26
Any idea?

Trash your code, buy a book, and start over.

Welcome.
 

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,994
Messages
2,570,222
Members
46,810
Latest member
Kassie0918

Latest Threads

Top