[REBOL] Re: printing javascript tags
From: al:bri:xtra at: 6-Feb-2001 16:19
T Brownell wrote:
> <SCRIPT>
> document.cookie = 'CookiesEnabled=1';
> if (document.cookie == ' ') {
> {document.location.href='http://www.yourdom.com';}
>
> </SCRIPT>
The first left brace on this line:
{document.location.href='http://www.yourdom.com';}
shouldn't be there.
A function that could be handy for your work is:
JavaScript: func [Text [file! url! string!]][
either string? Text [
rejoin [""
<script type="text/javascript" language="JavaScript">
"<!-- " newline
Text newline
"//-->"
</script>
newline
]
][
rejoin [""
join <script type="text/javascript"
language="JavaScript"> [
{ src="} Encode Text {"}
]
</script>
newline
]
]
]
It can be used like:
JavaScript %eText.js
or for your example:
JavaScript {
document.cookie = 'CookiesEnabled=1';
if (document.cookie == ' ') {
document.location.href='http://www.yourdom.com';
}
}
then you can see that the braces are matched and it even flows logically
and with the same white space formatting as the surrounding script. Plus it
hides the JavaScript from browsers that don't know about it.
Andrew Martin
ICQ: 26227169 http://members.nbci.com/AndrewMartin/