/    Sign up×
Community /Pin to ProfileBookmark

How can I change the class name in Netscape

I’d like to change the class name dynamically.
Like that,
myIdName.className = “request”;
It could work well in IE but couldn’t run in Netscape.
Please give me some suggestions concerned with Netscape compatible script .

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@fredmvJan 01.2004 — This works fine for me in Mozilla:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="content-type" content="application/xhtml+xml; charset=iso-8859-1" />
<style type="text/css">
/*<![CDATA[*/
.class1 {
color: #f00;
}

<i> </i> .class2 {
<i> </i> color: #00f;
<i> </i> }
<i> </i> /*]]&gt;*/
<i> </i> &lt;/style&gt;
<i> </i>&lt;/head&gt;
<i> </i>&lt;body&gt;
<i> </i> &lt;div onmouseover="className='class1';" onmouseout="className='class2';"&gt;
<i> </i> foo
<i> </i> &lt;/div&gt;
<i> </i>&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@MagnoliaKobusauthorJan 01.2004 — I used the following code. If so, how could I change ?

<html>

<head>

<title>Script Testing</title>

<style type="text/css">

.normtext

{

BACKGROUND-COLOR: #006699

}

.selecttext

{

BACKGROUND-COLOR: #f5deb3

}

</style>

<script language=javascript>

function changeClass(){

var src = window.event.srcElement;

if (src.parentElement.id == "myId"){

if(myId.className == "normtext")

myId.className = "selecttext";

else

myId.className = "normtext";

}

}

</script>

</head>

<body>

<form name=frm>

<table border=0 cellspacing=0 cellpadding=0 width=50% align=center>

<tr id=myId class=normtext onclick=changeClass(); height="5px">&nbsp;<td></td></tr>

</tabel>

</form>

</body>

</html>
Copy linkTweet thisAlerts:
@ray326Jan 01.2004 — It's a lot easier if you just pass the element to the handler:

function changeClass(src){

if (src.id == "myId"){

if(src.className == "normtext")

src.className = "selecttext";

else

src.className = "normtext";

}

And

<tr id="myId" class="normtext" onclick="changeClass(this);" height="5px">
Copy linkTweet thisAlerts:
@MagnoliaKobusauthorJan 02.2004 — "myId.className"

It doesn't work in Netscape.
Copy linkTweet thisAlerts:
@ray326Jan 02.2004 — [i]Originally posted by MagnoliaKobus [/i]

[B]"myId.className"

It doesn't work in Netscape. [/B]
[/QUOTE]

Did you actually read what fredmv and I posted?
Copy linkTweet thisAlerts:
@fredmvJan 02.2004 — [i]Originally posted by ray326 [/i]

[B]Did you actually read what fredmv and I posted? [/B][/QUOTE]
I was just thinking the same thing. ?
×

Success!

Help @MagnoliaKobus spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...