Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Using Rhino and E4X to generate HTML?

8 views
Skip to first unread message

chris....@gmail.com

unread,
Jun 5, 2006, 7:18:49 AM6/5/06
to
I thought E4X might be useful to generate HTML or XHTML pages but I've
struck a small problem involving the <SCRIPT> tag and was wondering if
anyone could offer suggestions or a workaround.

Most browsers seem to want the SCRIPT tag to have an explicit closing
tag:

<script type="text/javascript" src="somefile.js"></script>

E4X will generate this as <script type="text/javascript"
src="somefile.js"/> which gets ignored by some browsers.

Is it possible to force the generation of the closing tag? Or get E4X
to print it's output in compatible HTML instead of XML?

Chris.
--
http://www.bluishcoder.co.nz

Martin Honnen

unread,
Jun 5, 2006, 7:44:34 AM6/5/06
to
chris....@gmail.com wrote:

> I thought E4X might be useful to generate HTML or XHTML pages but I've
> struck a small problem involving the <SCRIPT> tag and was wondering if
> anyone could offer suggestions or a workaround.
>
> Most browsers seem to want the SCRIPT tag to have an explicit closing
> tag:
>
> <script type="text/javascript" src="somefile.js"></script>
>
> E4X will generate this as <script type="text/javascript"
> src="somefile.js"/> which gets ignored by some browsers.

Don't generate XHTML and send it to browsers that do not understand
XHTML. If you send XHTML written according to XML rules to browsers like
IE which only understand HTML parsed as text/html then you are in
trouble. That is why the XHTML 1.0 specification does not only specify
the XHTML rules but also has an appendix on how to author XHTML in a way
to be backwards compatibe with text/html user agents. I don't think E4X
has any mode to support that appendix so it is not suitable to generate
HTML.

--

Martin Honnen
http://JavaScript.FAQTs.com/

biju

unread,
Jun 6, 2006, 12:34:20 AM6/6/06
to
try following code (a js comment between script tag)

mypage = <html>
<head>
<title>HTML using E4X</title>
<script type="text/javascript" src="somefile.js">/* */</script>
</head>
<body>HTML using E4X with a script tag
</body>
</html>


or till https://bugzilla.mozilla.org/show_bug.cgi?id=337018
fixed you can use, (a space between script tag)

mypage = <html>
<head>
<title>HTML using E4X</title>


<script type="text/javascript" src="somefile.js"> </script>

</head>
<body>HTML using E4X with a script tag
</body>
</html>

0 new messages