Following is a piece of code mixed with perl and javascript:
If I omitted 'escape()' once either in perl or js code, then I would get a run time javascript error:
Error: Expected ';'
To me, I would think it should be sufficient to escape once in the perl code.
Could someone explain it to me why? Many thanks.
Code:
# some perl codes here
my $words = "It's a test";
$words = escape($words); [b]# escape once![/b]
my $jscode =<<BLAARG;
// It does not make a difference using double or single quotes in the folowing line
var words = escape("$words"); [b]// escape twice!![/b]
function myfunction() {
// some js codes here
var url = '/myperl.pl&words=' + words;
var name = 'newWin';
open(url, name);
}
BLAARG
If I omitted 'escape()' once either in perl or js code, then I would get a run time javascript error:
Error: Expected ';'
To me, I would think it should be sufficient to escape once in the perl code.
Could someone explain it to me why? Many thanks.