Re: [問題] 這是什麼道理阿
據 HTML 4.01 Specification 裡頭所寫的:
(ref: http://www.w3.org/TR/html4/interact/scripts.html#h-18.3.2 )
Commenting scripts in JavaScript
 The JavaScript engine allows the string "<!--" to occur at the
 start of a SCRIPT element, and ignores further  characters until
 the end of the line. JavaScript interprets "//" as starting a
 comment extending to the end of the current line. This is needed
 to hide the string "-->" from the JavaScript parser.
大意是說 javascript 直譯器看到最開頭的 <!--
會直接把該行整個當註解
這樣應該可以解釋這個問題 :)
※ 引述《kc655039 (NNN   )》之銘言:
: 我再html裡面隨便插入一段javascript:
:                                 <script language=javascript>
:                                 <!--
:                                     IsShow(1);
:                                 //-->
:                                 </script>
: 這樣可以正常執行沒有問題,
: 如果<script language=javascript>IsShow(1);</script>
: 也可以正常,
: 但是如果:<script language=javascript><!--IsShow(1);--></script>
: 就沒有反應,
: 其實顯然地三個會被當成註解??
: 可是html怎會跟排列的方式有關??
: 有沒有人知道這個的答案呢??
--
※ 發信站: 批踢踢實業坊(ptt.cc) 
◆ From: 140.112.30.52
推
11/15 07:12, , 1F
11/15 07:12, 1F
討論串 (同標題文章)
Web_Design 近期熱門文章
PTT數位生活區 即時熱門文章