Results 1 to 8 of 8

Thread: Using problem with <div> tag in Netscape

  1. #1
    VBSpike
    Guest

    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

  2. #2
    VBSpike
    Guest
    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

  3. #3
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    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

  4. #4
    PowerPoster sail3005's Avatar
    Join Date
    Oct 2000
    Location
    Chicago, IL, USA
    Posts
    2,340
    yeah, thats probably faster

    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA
    USAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSAUSA

  5. #5
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    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

  6. #6
    Conquistador
    Join Date
    Dec 1999
    Location
    Australia
    Posts
    4,527
    That doesn't look like div tags, whoever said that...?

  7. #7
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    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

  8. #8
    Frenzied Member
    Join Date
    Feb 2001
    Posts
    1,140
    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
  •  



Click Here to Expand Forum to Full Width