SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Safari/IE vs. Firefox (and a bug involving div id="100")

    Hi, folks.

    First off, the actual HTML and JS:
    calendar_bug.php
    scheduling.js

    bug #1:

    I've got some JS code that's working only in Firefox - IE and Safari have problems.

    In Firefox, clicking a start time and an end time works correctly. In IE/Safari, though, it fails immediately on clicking a start time.

    It seems to be related to the following code:
    Code:
    		 	if(document.getElementById(i).className != 'manyplanes' && document.getElementById(i).className != 'fewplanes' && i!=startDiv) {
     		 		alert('Some times within your selection are invalid.');
      					break;
      				}
    bug #2:

    In Firefox (the only one working right now) any date range that includes div #100 fails. Everything else works just fine. Any ideas?

    Thanks in advance for help!
    Last edited by ceejayoz; Feb 14, 2005 at 08:54.

  2. #2
    SitePoint Zealot
    Join Date
    Jan 2005
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    var isIE = ((document.all && !isNS) ? true : false);
    var isNS = ((document.getElementById && !isIE) ? true : false); 
    
    function getRef(id) {
    	if (isNS) return document.getElementById(id);
    	if (isIE) return document.all[id];
    }
    So basically Gecko based browsers uses document.getElementById(id) and IE browsers uses document.all[id]

    I hope I am right.

  3. #3
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    getElementById seems to work just fine in all three browsers with the offending code removed, though.

  4. #4
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By specification, ID's should never start with a numeral. In other words, "100" is an illegal ID.

    document.all is IE 4, carried on through later versions. document.getElementById() is W3C DOM 1, found in IE 5 and later, as well as Moz, Opera, Safari, et. al.

  5. #5
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can that be the problem if 1-99 and 101+ are working without problems in FF?

  6. #6
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Some browsers are more forgiving of the error than others. Just try validating a page with an ID that starts with a numeral and you'll see what I mean: http://validator.w3.org/

    Since that is a known problem, you'll need to fix it first before we'll be sure that it isn't the source of the failure. (Note: You can use numbers within the ID, you just can't start the ID with a numeral.)

  7. #7
    SitePoint Evangelist gollux's Avatar
    Join Date
    Feb 2005
    Location
    Oregon, USA
    Posts
    414
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What's with this eh?

    I was always under the impression that class and ID selectors could be alphanumeric but never start with a number. So here's a test for Jigsaw:

    #100x {text-align: center; border: 5px red double; }
    .101x {text-align: center; border: 5px red double; }

    Which then gives me the following burst of information and corrected CSS:

    Errors
    URI : file://localhost/TextArea

    * Line: 2 Context : .\3101x

    In CSS1, a class name could start with a digit (".55ft"), unless it was a dimension (".55in"). In CSS2, such classes are parsed as unknown dimensions (to allow for future additions of new units) : To make ".101x" a valid class, CSS2 requires the first digit to be escaped (".\3101x")

    Valid CSS information

    #100x {
    text-align : center;
    border : 5px double red;
    }
    .\3101x {
    text-align : center;
    border : 5px double red;
    }

    Ok, what gives? It definitely tells me about why a class shouldn't start with a number, but says nothing about an ID. I've been trying to find where, chapter and verse it is laid out what makes a proper class or ID name and all I've gotten so far is "alphanumeric" and "no underscores".

    Dug in a little further and found it.. The "no underscores" was a Netscape bug.

    http://www.w3.org/TR/html401/types.html#h-6.2

    ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
    Last edited by gollux; Feb 5, 2005 at 22:54.

  8. #8
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    *tears hair out*

    I figured out bug #1.

    There were spaces in the class - it went class=" manyplanes". Mozilla apparently trims the whitespace off it, so the code worked fine. IE and Safari do not. It now works.

    Three hours on that! Argh!

    Bug #2 remains...

  9. #9
    SitePoint Zealot
    Join Date
    Feb 2002
    Location
    Rochester, NY
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Figured out a kludge for bug #2 - I added 1000 to all the div numbers, thus eliminating the #99 --> #100 transition.

    I'd still love to know why it was happening, though.


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
  •