JavaScript not working in XHTML -
i trying make xhtml page javascript. javascript not work.
i have written simplest file, can not find error. me seems fine. please, give me advice.
<!doctype html> <html version="-//w3c//dtd xhtml 1.1//en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://www.w3.org/1999/xhtml http://www.w3.org/markup/schema/xhtml11.xsd"> <head> <title>xhtml test</title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta charset="utf-8" /> <meta name="description" content="xhtml test" /> <meta name="keywords" content="xhtml, test" /> <link rel="stylesheet" type="text/css" href="a.css" /> <script type="application/javascript" charset="utf-8" src="a.js" defer="defer"></script> <script type="application/javascript"> function init() { alert('x'); } </script> </head> <body onload="init();"> <div id="main" class="c1"> xhtml test. </div> </body> </html>
i have tried external js file , inline script inside <script>
. neither works me.
the document saved index.xhtml
, served apache should: content-type: "application/xhtml+xml"
if rename file index.html
served html , script works. need xhtml.
thank you.
xhtml has case-sensitive tag , attribute names. must lower case.
you have written onload
instead of onload
.
Comments
Post a Comment