javascript - <script></script> or <script />? -


possible duplicate:
why don't self-closing script tags work?

i found weired behavior script tag in html.

i web server nginx, , used fast cgi , php5. have page.html, looks this:

<html>   <body>     <!-- <?php echo 'i going add php code here'; ?> -->     <script type="text/javascript" src="./my/javascript1.js" />     <script type="text/javascript" src="./my/javascript2.js" />   </body> </html> 

if page served directly web server, java script works well. if passed php5, seems first java script tag executed. if change script block into:

    <script type="text/javascript" src="./my/javascript1.js"></script>     <script type="text/javascript" src="./my/javascript2.js"></script> 

everything works again. noticed how tags closed? yeah, why asking here. difference? supposed have same function/meaning. besides, output html web browser (chrome/ie9) received same, why treated differently?

the script tag needs separate closing tag valid code. see http://www.w3.org/tr/html401/interact/scripts.html#h-18.2.1

some browsers accept self closing tag, others wont, , html version using affects result. there not self closing tags unless use xhtml.

passing file through php engine should not change result, it's possible makes attempt correct incorrect script tags. should view source in browser see if tags has been changed.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -