I tend to use the stray < or > inside the script, rather than resort to a CDATA section, but both are valid.
 
You may be missing the point of the output-symbol.  It is for defining strings to communicate back to the code or component that invoked the script.
 
When you want the JavaScript to be included on the page, put it inside the <body> or <initialization> tag.  Generally,you put your event handling functions inside the <body> tag, and but any initialization (such as setting the event handlers for a component) inside the <initialization> tag (JavaScript inside the <initialization> tag is executed from the HTML <body> element's onload event handler).
----- Original Message -----
Sent: Tuesday, October 15, 2002 5:08 AM
Subject: [Tapestry-developer] Javascript and output symbols

Hello!
 
I'm trying to use an output symbol with the script component, but I'm having a bit of a problem.
 
My script file look like this:
 
=============================================================
 
<?xml version="1.0"?>
<!-- $Id: Publisher.script,v 1.4 2002/09/27 12:13:24 hship Exp $ -->
<!DOCTYPE script PUBLIC
 "-//Howard Lewis Ship//Tapestry Script 1.2//EN"
 "http://tapestry.sf.net/dtd/Script_1_2.dtd">
 
<script>
 
<let key="test">
function test() {
  var x = 0;
  var y = 1;
  if (x < y)
    document.write("<p>Testing, x</p>");
  else
    document.write("<p>Testing, y</p>");
}
</let>
 
<body/>
<initialization/>
 
</script>
 
=============================================================
 
When I want to use this script I get a complain about the < and the > so I enclose the function in a CDATA section. But now the problem is when I try to output the function to the html page, the < and > is converted to &lt; and &gt;. This is ok for viewing, but when the javascript contains "if (x &lt; y)" the browser shudders and spits out an error dialog.
 
Is there some way around this?
 
regards,
 
Niklas

niklas.ekman
citat solutions | phone +46 (0)31 710 72 12
kronhusgatan 9, SE-411 05 g�teborg, sweden,
[EMAIL PROTECTED]

 

Reply via email to