html與xhtml中javascript區(qū)別

字號:


    區(qū)別一
    xhtml出現(xiàn),js也做了相應(yīng)地改變,標(biāo)簽不再用language地特性.用type特性來聲明內(nèi)嵌代碼或者要加入外部文件地mime類型.
    區(qū)別二
    xhtml實(shí)用了cdata代碼段.比如特殊字符 <, > ,& ,不必用他們地字符實(shí)體,而是用代碼
    舉例說明
    <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í)用到cdata
    <script type = 'text/javascript'>
    <![cdata[
    if(1>2){alert(true!;)}
    ]]>
    </script>