A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: XHTML and JAVASCRIPT problem!

  1. #1

    XHTML and JAVASCRIPT problem!

    Everyone know that there is a code must be put on today's website,it is "<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">" in order to get close to standard that we say today.but there is a problem that when I use javascript in its website which containning that code cann't run,but when I wipe off that code, the javascript just can run correctly.I don't know what's the problem,or the W3C organization is not allowed to use the javascript,is there anyone can help me.it will be very kind of you

    Anyone know can reply on this or anyheart person can email me,my email box is kevin19840531@hotmail.com. Thank you very much!

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    What javascript are you trying to use?

    I think it would be very rare that adding a doctype would modify script behaviour (at the moment I can only think of one case in internet explorer 6 with the use of document.documentElement vs document.body). Commonly all the doctype is used for by the browser is to switch into a "standards compliant" rendering mode - that is it displays HTML and CSS more strictly.

    It's only when you actually serve XHTML as an XML application (very few people do this - since it isn't supported in Internet Explorer) where javascript would behave differently (e.g document.write isn't allowed, tag names are case sensitive and in lowercase etc...)

  3. #3
    thank you,catbert303!if it's as you say,so what's the problem with this ,I put on a example here,please take a look!



    The first one is run right,and the second is run wrong,and it's different is just the code following:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">

    Can you tell me why?thank you!

  4. #4
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    One thing that is wrong is that the css,

    border: buttonface 1 solid;

    is meaningless - the order of the properties is wrong.

    it should be,

    border: 1px solid buttonface;

    IE applies error correction to this when in quirks mode (without the doctype) but not in standards mode.

    This means that when the page doesn't have a doctype

    parseInt(scrollDiv.currentStyle.borderBottomWidth) and parseInt(scrollDiv.currentStyle.borderRightWidth)

    are both 1 (I guess IE decides that 1 is the only value that looks like a width in the declaration, and uses that despite the properties being in the wrong order)

    but when the page does have a doctype they are both

    NaN (not a number) I think this will be causing a lot of the calculations to fail. This happens because IE couldn't get a valid width from the CSS, so it correctly defaulted the border width to the value "medium". Clearly trying to convert the string "medium" into a number using parseInt will fail

    Another potential problem is that in standards mode values for widths, heights etc... set through CSS require units. So setting,

    someObj.style.width = 200;

    would not work correctly, it would need to be,

    someObj.style.width = '200px';

    in quirks mode internet explorer (I think) assumes unitless values are in pixels.

  5. #5
    very thank you,catbert303!I will take a look!thank you again!~

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

HTML5 Development Center