Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

printing javascript tags

 [1/8] 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/

 [2/8] from: terry:depotcity at: 6-Feb-2001 1:55


Hmm. Doesn't choke, but doesn't work either? Is there some known method for Rebol to check if the user accepts cookies? Of course, you can bake a cookie, then if not found? on the next pass, but that requires an extra step. I would rather redirect on the first pass.. either found? cookie [do this][do that] Terry Brownell

 [3/8] from: al::bri::xtra::co::nz at: 6-Feb-2001 23:19


Terry Brownell wrote:
> Hmm. Doesn't choke, but doesn't work either?
I have around 300+ HTML pages that use this function? It seems to work OK for them. I may have mistyped something in my pasting into the email?
> Is there some known method for Rebol to check if the user accepts cookies?
I believe you need JavaScript (or JScript or BASIC for MSIE) to do this. Andrew Martin ICQ: 26227169 http://members.nbci.com/AndrewMartin/

 [4/8] from: terry:depotcity at: 6-Feb-2001 10:50


The function works fine. It's the javascript that's not performing. Other javascripts on the page work. What's with this one? Terry Brownell

 [5/8] from: terry:depotcity at: 5-Feb-2001 16:42


Hello All, Simple question(?) How do you form and print the following javascript.... <SCRIPT> document.cookie = 'CookiesEnabled=1'; if (document.cookie == ' ') { {document.location.href='http://www.yourdom.com';} </SCRIPT> ...seeing that it contains semi-colons, single quotes and curly braces? I keep getting a incorrect string error no matter how it's formed. Thanks, T Brownell PS This js checks to see if the user accepts cookies or no.

 [6/8] from: gjones05:mail:orion at: 5-Feb-2001 19:02


Hi, T, Maddening sometimes, isn't it? Looks like you have an extra curly brace (there are two between the end of 'CookiesEnabled=1'; and if ... Re-try after deleting one and see if that is it. Worked fine for me anyway I tried. Hope that helps. --Scott

 [7/8] from: gchiu:compkarori at: 6-Feb-2001 14:07


On Mon, 5 Feb 2001 16:42:16 -0800 "Terry Brownell" <[terry--depotcity--com]> wrote:
> Simple question(?) > > How do you form and print the following javascript.... >
Do you try escaping the troublesome chars? -- Graham Chiu

 [8/8] from: kevin:sunshinecable at: 5-Feb-2001 17:15


On Mon, 5 Feb 2001, Terry Brownell wrote:
> How do you form and print the following javascript.... > <SCRIPT>
<<quoted lines omitted: 3>>
> </SCRIPT> > ...seeing that it contains semi-colons, single quotes and curly braces?
Terry, Matching number of left and right braces should do it. As the Core User Guide says, "multi-line strings are enclosed in brackets". What it doesn't say is that if you have embedded braces *inside* your string, you need to have a matching number of opens and closes. I think you've got one too many open braces. I added the extra close brace above </SCRIPT> to make it work: REBOL [] a: { <SCRIPT> document.cookie = 'CookiesEnabled=1'; if (document.cookie == ' ') { {document.location.href='http://www.yourdom.com';} } </SCRIPT>} print a Cheers, Kev

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted