Closed Thread Icon

Preserved Topic: Changing the Background Color of a Layer in Netscape Pages that link to <a href="https://ozoneasylum.com/backlink?for=17939" title="Pages that link to Preserved Topic: Changing the Background Color of a Layer in Netscape" rel="nofollow" >Preserved Topic: Changing the Background Color of a Layer in Netscape\

 
Author Thread
Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 04-27-2001 17:26

Arrrrggg!

This one's really begining to annoy me...

I'm trying to change the background color for a layer in netscape 4
Should this work...

document.layer["layerName"].document.bgColor = "color"

or

document.layers["layerName"].document.bgColor = "color"
(an extra 's' ^ here)


It just aint happening!!!!

Any help would be great thanks!

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 04-28-2001 08:20

document.layers["layerName"].bgColor = "#ff0000";

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 04-28-2001 09:00

Execelent! Thanks mr.maX!!

I think I've tried that one before before but I'll give it a go and If it doesn't work then I'll come back and whine some more....

Will this work with a <DIV> tag or only the <LAYER> tags?? oops... possibly should have said that to start with. But I'll run off and try this now... Thanks again .....

Dracusis

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 04-28-2001 10:00

ARRRRRGGG!!!!! I hate Netscape! This still doesn't seem to be working! Mabey I'm just doing something really wrong!


Here's what I'm working with at the moment....


code:
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!--

function setBGblue() {
document.layers["colourbox"].bgcolor = "#0000ff";
}

function setBGred() {
document.layers["colourbox"].bgcolor = "#ff0000";
}

//-->
</SCRIPT>
</HEAD>
<BODY>
<LAYER ID="colourbox" bgColor="#c0c0c0">A Simple<BR><BR>Test Layer</LAYER>
<BR>
<BR>
<BR>
<BR>
<A HREF="javascript: setBGblue()">Change layer Blue</A>
<BR>
<A HREF="javascript: setBGred()">Change layer Red</A>
</BODY>
</HTML>




I've already got this happening in IE 4+ with the <DIV> Tag, but I'd really like to get the same thing happening in NN 4+ with the <DIV>, however at the moment I can't even get things to work with a <LAYER> Tag!!!

Any help would be great thanks!

[This message has been edited by Dracusis (edited 04-28-2001).]

psych3
Nervous Wreck (II) Inmate

From: Australia
Insane since: Feb 2001

posted posted 04-29-2001 10:20

this works in NS4, NS6 and IE4+ for me

<html>
<head>
<title>Untitled Document</title>
<script>
function changeColor(name) {
if (document.all)
document.all.Layer1.style.backgroundColor = 'red';
else if (document.getElementById)
document.getElementById('Layer1').style.backgroundColor = 'red';
else if (document.layers)
document.Layer1.bgColor = 'red';
}

</script>

</head>

<body bgcolor="#FFFFFF" text="#000000">
<a href="#" onMouseover="changeColor()"> Change BG color </a>
<div id="Layer1" style="position:absolute; width:200px; height:115px; z-index:1; left: 203px; top: 84px; background-color: #0066FF; layer-background-color: #0066FF; border: 1px none #000000"></div>

</body>
</html>


----------------------
Eddie Traversa
DHTML NIRVANA
Multiple Award Winning Sites
Macromedia Resources & Various Other Goodies.
http://www.dhtmlnirvana.com/
--------------------------
Dynamic XHTML Developers Guide
Currently being written by Jeff Rouyer and little ol me
Let you know about a firm release date as soon as I know.
-----------------------------

psych3
Nervous Wreck (II) Inmate

From: Australia
Insane since: Feb 2001

posted posted 04-29-2001 10:23

oops you dont need the name arguement in that example but you could use it to id the layer and add another arguement to change the color so the event handler would end looking like this changeColor('Layer1', 'red') that way you wouldnt have to have a bunch of funtions handling different background colour changes.


----------------------
Eddie Traversa
DHTML NIRVANA
Multiple Award Winning Sites
Macromedia Resources & Various Other Goodies.
http://www.dhtmlnirvana.com/
--------------------------
Dynamic XHTML Developers Guide
Currently being written by Jeff Rouyer and little ol me
Let you know about a firm release date as soon as I know.
-----------------------------

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 04-29-2001 16:29

Dracusis, it won't work because JS is case-sensitive... So, you have to write it exactly as I wrote it ("bgColor" <- it has to be written like that, with big C)

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 04-29-2001 17:34

Yeah, thanks mr.maX.. I figured that one out on my own a yesterday... my bad

But I've got my script working well now thanks to you and psych3, nice and compact...

<SCRIPT LANGUAGE="JavaScript">
<!--
//---- Cross Browser Pointer Variable ----//
ns4 = (document.layers)? true:false
ie = (document.all)? true:false
ns6 = (document.getElementById)? true:false

function init() {
if (ie) {
colourButton = document.all["colourButtonDiv"].style
colourMenu = document.all["colourMenuDiv"].style
}
if (ns4) {
colourButton = document.layers["colourButtonDiv"]
colourMenu = document.layers["colourMenuDiv"]
}
if (ns6) {
colourButton = document.getElementById("colourButtonDiv").style
colourMenu = document.getElementById("colourMenuDiv").style
}
}


//---- Show & Hide Layer Function ----//
function showObject(obj) {
if (ie) obj.visibility = "visible"
else if (ns4) obj.visibility = "show"
else if (ns6) obj.visibility = "visible"
}

function hideObject(obj) {
if (ie) obj.visibility = "hidden"
else if (ns4) obj.visibility = "hide"
else if (ns6) obj.visibility = "hidden"
}


//---- Set Background Colour Of a Layer ----//
function setBGColor(obj, color) {
if (ie) obj.backgroundColor = color;
else if (ns4) obj.bgColor = color;
else if (ns6) obj.backgroundColor = color;
}

//-->
</SCRIPT>

Haven't gotten around to testing it with NS6 yet, but I should be able to fix any mistakes I find (Can't seem to Install NS6 on my work PC ... Getting a new Work PC soon ). It's been ages since I've had to code 'real' javascript in a web site, I got into a bad habbit of letting Dreamweaver do everything for me so I'm still warming up.


Thanks again Guy's (girl's ??) You Rock!!!!

Dracusis

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 04-29-2001 18:20

Try installing Mozilla instead of Shitscape 6...

Dracusis
Maniac (V) Inmate

From: Brisbane, Australia
Insane since: Apr 2001

posted posted 04-29-2001 19:31

I'll assume that Mozilla acts the same way as Netscape 6.....

I always thought that Mozilla was Netscape?? errgg.. I don't seem to have enough spare time to keep up with things now days....

Thanks fo the Tip mr.maX, Like always, you been a great Help!

Dracusis

mr.maX
Maniac (V) Mad Scientist

From: Belgrade, Serbia
Insane since: Sep 2000

posted posted 04-30-2001 08:38

Actually, it's the other way around. Shitscape 6 acts like Mozilla, because it is based on Mozilla's source code...

« BackwardsOnwards »

Show Forum Drop Down Menu