over has no properties

M

Matt

here's some more code i inherited on a project:

function set_background(pic){
if(pic==""){
if(ie4)over.backgroundImage="none";
if(ns6)over.style.backgroundImage="none";
}else{
if(ns4){
over.background.src=pic;
}else if(ie4){
over.backgroundImage="url("+pic+")";
}else if(ns6){
over.style.backgroundImage="url("+pic+")";
}
}
}

i'm getting an error that says "over has no properties" when i look at
this in firefox. is this the wrong syntax for over
 
W

web.dev

Matt said:
here's some more code i inherited on a project:

function set_background(pic){
if(pic==""){
if(ie4)over.backgroundImage="none";
if(ns6)over.style.backgroundImage="none";
}else{
if(ns4){
over.background.src=pic;
}else if(ie4){
over.backgroundImage="url("+pic+")";
}else if(ns6){
over.style.backgroundImage="url("+pic+")";
}
}
}

i'm getting an error that says "over has no properties" when i look at
this in firefox. is this the wrong syntax for over

The syntax is correct. However, what I would like to know is what is
"over" referencing to? From the looks of all that you gave, over is a
global variable. Has "over" been assigned something in the global
scope? Double check to make sure "over" is referencing something.
 
G

Gérard Talbot

Matt wrote :
here's some more code i inherited on a project:

function set_background(pic){
if(pic==""){
if(ie4)over.backgroundImage="none";

I doubt IE4 supports background-image anyway
if(ns6)over.style.backgroundImage="none";
}else{
if(ns4){
over.background.src=pic;
}else if(ie4){
over.backgroundImage="url("+pic+")";

I doubt IE4 supports background-image anyway
}else if(ns6){
over.style.backgroundImage="url("+pic+")";
}
}
}

i'm getting an error that says "over has no properties" when i look at
this in firefox. is this the wrong syntax for over

You need to define the id attribute for such element. Then you can
access such element with document.getElementById: this creates a
reference to a scriptable node.

e.g.:

var ElementReference = null;

ElementReference = document.getElementById("over");

More on this and other issues:

Using Web Standards in Your Web Pages
http://www.mozilla.org/docs/web-developer/upgrade_2.html#dom_access

Gérard
 

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

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top