473,402 Members | 2,064 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Problems setting style attrabutes of multiple layers

I have a couple of layers that are hidden.

When an image is moused over, I want to show the appropriate layer,
then hide it on mouseOut.

The problem is, I get an error telling me "document.all[...].style is
not an object" for whatever layer I have created first. It seems as
though when the second layer is created, it overwrites the first one
....

This has been driving me NUTS! Any suggestions?

Heres my code:

javascript :

function helpWin(meth,obj){
if(meth=="show"){
document.all[obj].style.visibility = 'visible';
}else if(meth=="hide"){
document.all[obj].style.visibility = 'hidden';
}
}

HTML :

<!-- -->
<div id="bcc" style="position:absolute; border: 1px solid balck;
left:420px; top:0px; width:300px; height:50px; z-index:1;
background-color: #FFFFFF; layer-background-color: #FFFFFF;
visibility: hidden;">
<span class="mainTitle">Some Text</span></div>
<!-- -->
<div id="toc" style="position:absolute; border: 1px solid balck;
left:420px; top:0px; width:300px; height:50px; z-index:2;
background-color: #FFFFFF; layer-background-color: #FFFFFF;
visibility: hidden;">
<span class="mainTitle">Some Text</span></div>
<!-- -->

<img src="q.gif" width="10" height="10"
onMouseOver="helpWin('show','bbc');"
onMouseOut="helpWin('hide','bbc');">

<img src="q.gif" width="10" height="10"
onMouseOver="helpWin('show','toc');"
onMouseOut="helpWin('hide','toc');">
Jul 23 '05 #1
8 1437
Hi,

In article <c7**************************@posting.google.com >, Eclectic wrote:
solid balck;
it's definitely dangerous to use 'solid balck;'. I'd recommend a spell checker. Dreamweaver does a good job
for that kind of things.

For the other problem of yours,
The problem is, I get an error telling me "document.all[...].style is
not an object" for whatever layer I have created first. It seems as
though when the second layer is created, it overwrites the first one


Use this script, I don't remember where I got it from, and lost the copyright message, thanks to the author
anyway:

--------
function toggleVisibility(id, NNtype, IEtype, W3Ctype) {
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" + W3Ctype + "\"");
} else {
if (document.layers) {
document.layers[id].visibility = NNtype;
} else {
if (document.all) {
eval("document.all." + id + ".style.visibility = \"" + IEtype + "\"");
}
}
}
------------------

you use it like:

onMouseOut="toggleVisibility('bcc','hidden','hidde n','hidden');
onMouseOver="toggleVisibility('toc','show','visibl e','visible');

you can use it for any number of objects, for any kind of event. It's very convenient and works with (AFAIK)
every browser.

Ranbir
Jul 23 '05 #2
Ranbir Kaur wrote:
<snip>
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" +
W3Ctype + "\"");

<snip>
This has got be the most futile use of - eval - posted in a long time:-

document.getElementById(id).style.visibility = W3Ctype;

Richard.
Jul 23 '05 #3
Richard Cornford wrote:
Ranbir Kaur wrote:
<snip>
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" +
W3Ctype + "\"");

<snip>
This has got be the most futile use of - eval - posted in a long time:-

document.getElementById(id).style.visibility = W3Ctype;


Not this way, see <http://www.pointedears.de/scripts/test/whatami>.
Instead write:

var t;
if ((t = typeof document.getElementById) == "function"
|| (t == "object" && document.getElementById))
{
var o = document.getElementById(id), s;
if (o
&& typeof o.style != "undefined"
&& typeof o.style.visibility != "undefined")
{
o.style.visibility = W3Ctype;
}
}
PointedEars
--
Life is like a french fry. It gets cold, it gets soggy, and it gets limp if
you let it lying around too long.
Jul 23 '05 #4
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Ranbir Kaur wrote:
<snip>
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" +
W3Ctype + "\"");

<snip>
This has got be the most futile use of - eval - posted
in a long time:-

document.getElementById(id).style.visibility = W3Ctype;


Not this way, see <http://www.pointedears.de/scripts/test/whatami>.
Instead write:

<snip>

This has nothing to do with the futility of the - eval - formulation
used. If you want to talk about the code design it would make most sense
to post a response to individual who designed it, not me.

Richard.
Jul 23 '05 #5
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Ranbir Kaur wrote:
<snip>
if (document.getElementById) {
eval("document.getElementById(id).style.visibility = \"" +
W3Ctype + "\"");
<snip>
This has got be the most futile use of - eval - posted
in a long time:-

document.getElementById(id).style.visibility = W3Ctype;


Not this way, see <http://www.pointedears.de/scripts/test/whatami>.
Instead write:

<snip>

This has nothing to do with the futility of the - eval - formulation
used. If you want to talk about the code design it would make most sense
to post a response to individual who designed it, not me.


I commented on your inappropriate correction.
PointedEars
--
PROZAC: Sometimes you feel like a nut, sometimes you don't.
Jul 23 '05 #6
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Ranbir Kaur wrote:
<snip>
> if (document.getElementById) {
> eval("document.getElementById(id).style.visibility = \"" +
> W3Ctype + "\"");
<snip>
This has got be the most futile use of - eval - posted
in a long time:-

document.getElementById(id).style.visibility = W3Ctype;

Not this way, see http://www.pointedears.de/scripts/test/whatami
Instead write:

<snip>

This has nothing to do with the futility of the - eval -
formulation used. If you want to talk about the code design
it would make most sense to post a response to individual who
designed it, not me.


I commented on your inappropriate correction.


Are you proposing that I did not post the code for the equivalent
operations without the eval?

In any event, my post was not a correction it was an observation of
manifest futility. And frankly, referring me to your pathetic page on
feature detection, or posting your clunky and pedestrian feature
detection example, looks like trying to teach your grandmother to suck
eggs.

Richard.
Jul 23 '05 #7
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
> Ranbir Kaur wrote:
> <snip>
>> if (document.getElementById) {
>> eval("document.getElementById(id).style.visibility = \"" +
>> W3Ctype + "\"");
> <snip>
> This has got be the most futile use of - eval - posted
> in a long time:-
>
> document.getElementById(id).style.visibility = W3Ctype;

Not this way, see http://www.pointedears.de/scripts/test/whatami
Instead write:
<snip>

This has nothing to do with the futility of the - eval -
formulation used. If you want to talk about the code design
it would make most sense to post a response to individual who
designed it, not me.


I commented on your inappropriate correction.


Are you proposing that I did not post the code for the equivalent
operations without the eval?


I am proposing that your correction is presenting a still
inappropriate approach, although it is better than using
eval(...). Don't you understand "Not this way"?
PointedEars
Jul 23 '05 #8
Thomas 'PointedEars' Lahn wrote:
Richard Cornford wrote:
Thomas 'PointedEars' Lahn wrote: <snip>
I commented on your inappropriate correction.


Are you proposing that I did not post the code for the
equivalent operations without the eval?


I am proposing that your correction is presenting a still
inappropriate approach, although it is better than using
eval(...). Don't you understand "Not this way"?


And once again you have cut the part of my post where I stated that my
first post to this thread was an observation not a correction, and then
replied as if that statement had not been made.

Richard.
Jul 23 '05 #9

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

Similar topics

4
by: Ian Rastall | last post by:
This really is a JavaScript question. I have a site that looks fine in everything but NN4. I'm afraid I don't have a URL, because the site is very much unfinished. The site is a header (which is...
6
by: Ingmund Sjåstad | last post by:
Trying to make a dropdown menu. I working nice in IE6 but when I try a link in Netscape 7 nothing happens. Can anybody help me? <html> <head> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
13
by: murali | last post by:
Hello everyone, I used absolute positioning with div tag in my website. The page looks cool as long as someone doesn't try to zoom in by increasing the text size (ctrl++ or thru changing font...
2
by: ALuPin | last post by:
Hi, when I try to see the effect of the following script I do not see anything when using Netscape Navigator whereas InternetExplorer ist ok. In Netscape Javascript is activated. What could...
11
by: brian.newman | last post by:
I'm trying to use a layer inside a form to hide/reveal a part of the form, but my code doesn't seem to be working and I need some help debugging it. I'm not getting an error which has made it...
2
by: cbjewelz | last post by:
Hey all. So I'm having problems with cross browser alignments. I'm looking at Safari and Mozilla Firefox. I develop in Safari and so it looks perfect there however in Firefox my vertical...
2
by: funkiejunkie | last post by:
Hello all, I posted a thread a while ago and was told to include the code so here it is. I still dont really get CSS, everything I have done has been blagged because I cant be bothered to read...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.