SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    Sausalito, Ca
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Netscape is the Devil

    Ok, I have now spent hours trying to figure out what, exactly is the problem here. I know how to make it work, but I don't know why the below does not work:

    Code:
    var genreText = new Array;
     
     genreText[0] = "rock"
     genreText[1] = "reggae"
     genreText[2] = "jazz"
     genreText[3] = "ambient"
     genreText[4] = "house"
     genreText[5] = "classical"
    
      document.write("<br>");
      for(x = 0;x < genreText.length;x++) {
    
      document.write("<a href=\""+ genreText[x] +".html\" target=\"main\"><font style=\"font-family: verdana, arial, helvetica;font-weight: bold;font-size: 12px;color: #ffffff\">"+ genreText[x] +"</font></a><br>");
    
    }

    I have done some research at this point, and there appears to be issue with using the style tag in a document.write with NN. WHY?!?!?!

    The above code works fine in IE, and if I take out the style tag, it works in NN.

    I know there are other ways to do what I am trying to do, but I am a curious guy, I want to know why this doesn't work.

  2. #2
    SitePoint Zealot Drew630's Avatar
    Join Date
    Nov 2001
    Location
    Maryland
    Posts
    175
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The short answer is that Netscape and IE have different protocals for Web authroing. Basically, the standards for each browser are different, so to program for one, might not do it for another. Irritating, I know.

    There are many solutions. First, update your Netscape browser to the highest version, I believe NEtscape 6.1.2 The newest of both IE and Netscape follow the W3 standards, so odds are that your page will run fine in Netscape 6. However, many people out there, for whatever compelling reason, still run Netscape 4, and sometimes lower versions. The best solution, to accomodate the most borwsers, is to build a cross-browser DOM. The DOM is the Document Object Model, simply put, the standards that a broswer version uses to interpret web pages. By building a simple script, you can determine the type of browser being used, and the type of DOM your page needs to use when it loads.

    I am in the process of
    a. learning more about this
    b. trying to build a cross-browser DOM from a book that I picked up.

    If I had one available, I would gladly share it, but I am still developing this marvel. If it does what my book says, then attaching it to your pages will automatically envoke a beroswer check and will (Cross you fingers) use the proper DOM to display my pages the way I want to. I hope this helps you better understand. If I have been in error in any of my explanation, feel free to correct me though.

    Drew
    ~Drew

    There Is No Greater Joy Than Soaring High On The Wings Of Your Dreams, Except Maybe The Joy Of Watching A Dreamer Who Has Nowhere To Land But In The Ocean Of Reality.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    Sausalito, Ca
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup, I know all about the DOM. What I found is this:

    this works:
    document.write("hello world");

    this works:
    document.write("<font face=\"arial\">hello world</font>");

    this worksnotice the style tage is empty)
    document.write("<font style=\"\">hello world</font>");

    this does not work:
    document.write("<font style=\"foo\">hello world</font>");

    this does not work:
    document.write("<" + "font style" + "=" + "\"foo\"" + ">" + "hello world" + "<" + "/" + "font" + ">");

    You are correct in saying that it does work better in the latest NN, but that will never do as I am developeing for 4.x browsers and above. Using a browser sniffer will help to determine who is using the offending versions of NN, but it wont fix the problem. In my private hell yesterday, I did find the following thread:

    check it out

    I do appreciate the response, I'm not sure if there is an answer other than, Netscape used to be great, now...

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A handy trick I use all the time is to use different quotes for inside and outside strings. Hard to explain, but here's an example:

    Code:
    document.write('<font style="foo">hello world</font>');
    Basically, if a JS string starts with a single quote (') then any double quotes (") are interpreted as part of the string, and so the problems you are having are avoided. The same goes for vice-versa, but HTML attributes really should have double quotes, so I always do it this way round (as above). I've never encountered any browser compatibility issues with this technique!


    M@rco

  5. #5
    We like music. weirdbeardmt's Avatar
    Join Date
    May 2001
    Location
    Channel Islands Girth: Footlong
    Posts
    5,882
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Plus you won't have to keep escaping the quotes, which is a common source of parse errors if you forget to escape a quote.
    I swear to drunk I'm not God.
    Matt's debating is not a crime
    Hint: Don't buy a stupid dwarf Clicky


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •