By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,282 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,282 IT Pros & Developers. It's quick & easy.

What are the Netscape-Mozilla equivalents?

P: n/a
Hi,

I've written some javascript routines for Internet Explorer and Opera.
Could you tell me the Netscape and Mozilla equivalents?

Thanks

-------------------------

//this works with Opera, not with Netscape and Mozilla:

var menuOpened = false;
var whatMenu = new Object();

function showMenu(menu){ //menu is the id of a DIV element

if ( menu == null ) return;

if (!menuOpened){
menu.style.visibility='visible';
menuOpened = true;
whatMenu = menu;
}
else{
menu.style.visibility='hidden';
menuOpened = false;
whatMenu = null;
}
}

-----------------

//this works only with Internet Explorer and Opera

var clicksBold = 0;

function toggleBold(){

clicksBold++;

SPANs = document.all.tags("SPAN");

for (var h = 0; h < SPANs.length; h++){
x = SPANs[h];
if (x.className == "aClassName"){
if ((clicksBold % 2) == 1) x.style.fontWeight = "bold";
else x.style.fontWeight = "normal";
}
}
}
-----------------

colors = new Array("blue","cyan","lightgreen","green","red","or ange","yellow","pink","violet","black","gray","whi te");
for (var j = 0; j < colors.length; j++){
document.write("<span style='background-color:" + colors[j] + ";
height:25; width:25; border-style:solid; border-width:1pt'></span>*");
}

//the output is a series of sqares in Internet Explorer and Opera,
some black lines in Netscape

--------------------------
//anID is the ID of a SPAN element

<select name="leftMargin"
onchange="anID.style.marginLeft=this.value;">
....
</select>
Jul 20 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
ca********************@yahoo.it (Simba) writes:
//this works only with Internet Explorer and Opera var clicksBold = 0; .... clicksBold++; I would use
var clicksBold = false;
...
clicksBold = ! clicksBold;
It better models what you want: toggling between on and off.
SPANs = document.all.tags("SPAN");

Use:
var SPANs = document.getElementsByTagName("SPAN");

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

P: n/a
DU
Simba wrote:
Hi,

I've written some javascript routines for Internet Explorer and Opera.
Could you tell me the Netscape and Mozilla equivalents?

Thanks

-------------------------

//this works with Opera, not with Netscape and Mozilla:

var menuOpened = false;
var whatMenu = new Object();

function showMenu(menu){ //menu is the id of a DIV element

if ( menu == null ) return;

if (!menuOpened){
menu.style.visibility='visible';
All 3 browsers and many other W3C DOM 1 compliant browsers (Safari 1.0,
Konqueror 3.1.x, MSIE 5.x for Mac, MSIE 5+, etc.) all support
document.getElementById("menu").style.visibility = "visible";
So, it is best for many reasons to use this manner of coding.

Using Web standards in your web pages
http://www.mozilla.org/docs/web-deve...upgrade_2.html

Updating DHMTL Web pages
http://devedge.netscape.com/viewsour...tml-web-pages/
menuOpened = true;
whatMenu = menu;
}
else{
menu.style.visibility='hidden';
menuOpened = false;
whatMenu = null;
}
}

-----------------

//this works only with Internet Explorer and Opera

var clicksBold = 0;

function toggleBold(){

clicksBold++;

SPANs = document.all.tags("SPAN");
Again, like Lasse said, best is to use

spanCollection = document.getElementsByTagName("SPAN");
which is widely and well supported by W3C DOM 1 compliant browsers.

for (var h = 0; h < SPANs.length; h++){
x = SPANs[h];
if (x.className == "aClassName"){
if ((clicksBold % 2) == 1) x.style.fontWeight = "bold";
else x.style.fontWeight = "normal";
}
}
}
-----------------

colors = new Array("blue","cyan","lightgreen","green","red","or ange","yellow","pink","violet","black","gray","whi te");
for (var j = 0; j < colors.length; j++){
document.write("<span style='background-color:" + colors[j] + ";
height:25; width:25; border-style:solid; border-width:1pt'></span> ");


There is a better alternative here to document.write.
DU
--
Javascript and Browser bugs:
http://www10.brinkster.com/doctorunclear/
- Resources, help and tips for Netscape 7.x users and Composer
- Interactive demos on Popup windows, music (audio/midi) in Netscape 7.x
http://www10.brinkster.com/doctorunc...e7Section.html

Jul 20 '05 #3

P: n/a
"Simba" <ca********************@yahoo.it> wrote in message
news:4e**************************@posting.google.c om...
<snip>
for (var j = 0; j < colors.length; j++){
document.write("<span style='background-color:" + colors[j] + ";
height:25; width:25; border-style:solid;border-width:1pt'></span> ");
}

<snip>

In addition to what Lasse and DU said, the CSS standard requires that
length values used with CSS properties should be provided with units
(px, em, ex, pt, pc, etc or percentages) and Mozilla browsers are
inclined to take a rather literal attitude towards the interpretation of
applicable standards. height:25; may be ignored for that reason alone,
however, the SPAN element is inline and non-replaced so CSS width and
height properties do not apply to it anyway.

Richard.
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.