Jonas Raoni wrote:
stefano escreveu: hi, I want to show some message in a box when the mouse is over a
button (examples: undo, save, open, ecc ) like in some interface.
There are thousands of tooltip codes over the web =]
Here is just another one...
http://jsfromhell.com/dhtml/tooltip
| <script type="text/javascript">
| //<![CDATA[
|
| new ToolTip(document.getElementById("a"), "primeira linha<br /><b>segunda
| linha</b>", "RED", true);
| new ToolTip(document.getElementById("b"), "primeira linha<br /><b>segunda
| linha</b>", "GREEN" );
|
| //]]>
| </script>
That is nonsense.
In XHTML, the `script' element's content model is PCDATA, so the
"<![CDATA[" will never be passed to the script engine; no need
to comment out anything.
In HTML, the `script' element's content model already is CDATA, so the "
[CDATA[" is passed as-is to the script engine, which will ignore it
because of the single-line comment; however, before the markup parser
passes that code to the script engine, it will look for the first
occurrence of the End Tag Open (ETAGO) delimiter "</" to delimit that
CDATA content; it can be found at "</b>", so what is passed to the
script engine is
| //<![CDATA[
|
| new ToolTip(document.getElementById("a"), "primeira linha<br /><b>segunda
| linha
which contains an unclosed string literal for the script engine, a
SyntaxError.
A reasonable approach would be to serve either XHTML as
application/xhtml+xml (with the disadvantage that IE does
not understand it) and use
<script ...>
<![CDATA[
...
]]>
</script>
or serve HTML as text/html and use
<script type="text/html">
new ToolTip(
document.getElementById("a"),
"primeira linha<br><b>segunda linha<\/b>", "RED", true);
new ToolTip(
document.getElementById("b"),
"primeira linha<br><b>segunda | linha<\/b>", "GREEN");
</script>
while creating ToolTip() objects that are subject to garbage-collection
directly after creation is still questionable.
PointedEars