html與XHTML中javascript區(qū)別

字號(hào):


    區(qū)別一
    Xhtml出現(xiàn),js也做了相應(yīng)的改變,標(biāo)簽不再用language的特性。用type特性來(lái)聲明內(nèi)嵌代碼或者要加入外部文件的mime類型。
    區(qū)別二
    XHTML實(shí)用了CDATA代碼段。比如特殊字符 <, > ,& ,"不必用他們的字符實(shí)體,而是用代碼
    舉例說(shuō)明
    <script type = 'text/javascript'>
    if(1>2){alert("true!";)}
    </script>
    但是在Xhtml
    <script type = 'text/javascript'>
    if(1 &gt; 2){alert("true!";)}
    </script>
    當(dāng)不用代碼標(biāo)識(shí)特殊字符時(shí)用到CDATA
    <script type = 'text/javascript'>
    <![CDATA[
    if(1>2){alert("true!";)}
    ]]>
    </script>
    這樣即可。