|
-
Oct 14th, 2001, 03:07 AM
#1
Using problem with <div> tag in Netscape
On my web page I need to change the text of certain paragraphs depending on the information entered by the user. I wrote a code using the <div> tag (gave it ID and formatted it the way I needed it) and then I started to write JavaScript code. After I finished coding I started testing. First IE - works perfectely. Then Netscape - nothing happens. And here is the problem - why doesn't anything happen in NS if it works perfectly in IE? I assume that it is one of these stupid things that work in one browser but not in the other due to differences in the implementation (duh!!). But anyway how can I do <div> style thing in Netscape?
Here is a sample code of what I did
<html>
<script language = "JavaScript">
function sayHi(){
test.innerText = "Hello VB-World";
}
</script>
<div id="test" style: blah blah blah blah you got the idea>text</div>
</html>
Thnx for any help
Spike
-
Oct 14th, 2001, 03:27 PM
#2
Yeah, I know that, but can you give me a sample code on how to use them. I try to copy something from the book I have and it just doesn't work in NS 6
-
Oct 14th, 2001, 06:38 PM
#3
PowerPoster
NS6 doesn't use layers, it uses divs. just like IE.
try using document.test.innerText=somehting;
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 14th, 2001, 06:59 PM
#4
PowerPoster
yeah, thats probably faster
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
-
Oct 15th, 2001, 02:23 AM
#5
Fanatic Member
actually to make it work you'd have to write something like this:
<html>
<script langauge=javascript>
function sayHI() {
\\IE 4.0+ Code:
if (document.all) {
test.innerHTML = "Hello VB-World";
}else if (document.getElementById) {
\\code for NS 6+
document.geteElementById["test"].innerHTML = "Hello VB-World";
}else if (document.layers) {
\\code for NS 4+
document.test.document.write("Hello VB-World");
}
}
</script>
<div id="test"></dic>
</html>
To be honest the last part for Netscape 4+ doesn't want to work (gives you an error document.test has no properties), but I'm sure that you can figure something out (I didn't but most of the visitors I get have very updated borwsers so I don't care about NS4).
But anyway the above should work just fine
Marek
-
Oct 15th, 2001, 03:04 AM
#6
Conquistador
That doesn't look like div tags, whoever said that...?
-
Oct 15th, 2001, 10:55 AM
#7
Fanatic Member
what do you mean? Of course it is div tags. That's the only way you'll make it work in Netscape. Only change this line:
document.geteElementById["test"].innerHTML = "Hello VB-World";
to
document.geteElementById( "test") .innerHTML = "Hello VB-World";
and it will work the way it should
Marek
P.S. Earl of Gonds' code won't work in NS6
-
Oct 15th, 2001, 11:33 AM
#8
Frenzied Member
Yes, well, getElementById (with one less e), but yes, that will work.
I tend to instantiate a JavaScript var to hold the address returned by getElement and the call the methods on it. But six half dozen of one....
Travis, Kung Foo Journeyman
As always, RTFM.
WWW Standards: HTML 4.01, CSS Level 2, ECMA 262 Bindings to DOM Level 1, JavaScript 1.3 Guide and Reference
Perl: Learn Perl, Llama, Camel, Cookbook, Perl Monks, Perl Mongers, O'Reilly's Perl.com, ActiveState, CPAN, TPJ, and use Perl;
YBMS, but Mozilla doesn't.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|