473,799 Members | 2,997 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.a ll[...].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,ob j){
if(meth=="show" ){
document.all[obj].style.visibili ty = 'visible';
}else if(meth=="hide" ){
document.all[obj].style.visibili ty = '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="mainTitl e">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="mainTitl e">Some Text</span></div>
<!-- -->

<img src="q.gif" width="10" height="10"
onMouseOver="he lpWin('show','b bc');"
onMouseOut="hel pWin('hide','bb c');">

<img src="q.gif" width="10" height="10"
onMouseOver="he lpWin('show','t oc');"
onMouseOut="hel pWin('hide','to c');">
Jul 23 '05 #1
8 1465
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.a ll[...].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 toggleVisibilit y(id, NNtype, IEtype, W3Ctype) {
if (document.getEl ementById) {
eval("document. getElementById( id).style.visib ility = \"" + W3Ctype + "\"");
} else {
if (document.layer s) {
document.layers[id].visibility = NNtype;
} else {
if (document.all) {
eval("document. all." + id + ".style.visibil ity = \"" + IEtype + "\"");
}
}
}
------------------

you use it like:

onMouseOut="tog gleVisibility(' bcc','hidden',' hidden','hidden ');
onMouseOver="to ggleVisibility( 'toc','show','v isible','visibl e');

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.getEl ementById) {
eval("document. getElementById( id).style.visib ility = \"" +
W3Ctype + "\"");

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

document.getEle mentById(id).st yle.visibility = W3Ctype;

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

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

document.getEle mentById(id).st yle.visibility = W3Ctype;


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

var t;
if ((t = typeof document.getEle mentById) == "function"
|| (t == "object" && document.getEle mentById))
{
var o = document.getEle mentById(id), s;
if (o
&& typeof o.style != "undefined"
&& typeof o.style.visibil ity != "undefined" )
{
o.style.visibil ity = 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.getEl ementById) {
eval("document. getElementById( id).style.visib ility = \"" +
W3Ctype + "\"");

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

document.getEle mentById(id).st yle.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.getEl ementById) {
eval("document. getElementById( id).style.visib ility = \"" +
W3Ctype + "\"");
<snip>
This has got be the most futile use of - eval - posted
in a long time:-

document.getEle mentById(id).st yle.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.getEl ementById) {
> eval("document. getElementById( id).style.visib ility = \"" +
> W3Ctype + "\"");
<snip>
This has got be the most futile use of - eval - posted
in a long time:-

document.getEle mentById(id).st yle.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.getEl ementById) {
>> eval("document. getElementById( id).style.visib ility = \"" +
>> W3Ctype + "\"");
> <snip>
> This has got be the most futile use of - eval - posted
> in a long time:-
>
> document.getEle mentById(id).st yle.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
5054
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 a table) and a main <div> underneath that. The main <div> is set to have a top margin of 3%, which works fine, except in NN4. There, it looks like it has a margin of 20%, or even larger. I couldn't fix it with the @import hack, so I thought I...
6
3097
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 Transitional//EN"> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>JS</title> </head>
13
40770
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 style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
13
3050
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 size in browser settings). When someone does that, the layers seem to overlap and the layer with a greater z value pops in front and the other layers are pushed back. The most obvious solution will be to prevent the user from increasing the text...
2
1430
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 be the problem? Thank you for your help.
11
2176
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 difficult to debug the code, but I am getting the alert ("break 4 in getStyleObject"); which makes me think this is a browser compatability issue (I'm running IE 6.0). Anyway, the code follows function getStyleObject (objectId) { alert ("begin...
2
17080
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 alignments and div widths are off. It's as if firefox has a different definition of a pixel than safari. Here is the url: http://theprize.chemouni.com/testing.php. When you select the Option from the pull down, the first part of the form appears. Then when...
2
1995
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 books to help me understand whats really going on. I would a few more containers within my centered text box in the middle so I dont have to press spacebar to get where I would like it, but have had trouble. I recon im doing a lot wrong so please...
0
9541
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10252
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10231
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10027
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9073
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.