I need to serve XHTML pages that include Javascript. My problem is that Firefox (3.5.7) seems to ignore the Javascript. For example:
<?xml version="1.0"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>My Title</title>
</head>
<body>
<script type="text/javascript">
document.write("Hello world!");
</script>
</body>
</html>
If I save this as test.html, Firefox displays this correctly. If I save this as test.xml, Firefox displays a blank page. What am I doing wrong here?
document.writedoes not work but settinginnerHTMLis still working. Just remember that whatever you set in there must be well-formed.This means that you can use jQuery to add new element/set html to any element.
I have a small library used for this. It work quite a bit.
You run
UseXHTMLDocWriteso thatdocument.writewill be replaced withXHTMLDocWriteif needed.This will simply add content to the last added element. However, it does not work with nested element.
NOTE: I modify the code of
XHTMLDocWritefrom the code I got from some where on the Internet and cannot seems to find it anymore. So sorry I can’t credit him.Hope this helps.