Forum Moderators: open
if (condition)
{
print "Content-type: text/html\n\n";
print <<ENDHTML;
<HTML>
<HEAD>
<TITLE>Details Successfully Added</TITLE>
<META http-equiv="CONTENT-LANGUAGE" content="EN">
etc
ENDHTML
}
else
{
do something else;
}
Can I use something similar in Javascript?
Thanks for any help.
(clarification.. it's the javascript equivalent of perl's 'print <<' I'm stuck on, not the conditional)
<script>
if (condition)
{
document.write("<HTML><HEAD><TITLE>Details Successfully Added</TITLE>");
document.write("<META http-equiv="CONTENT-LANGUAGE" content="EN">");
}
else
{
document.write("Test");
}
</script>
You won't have a true print since the client is building the page and not the server like with perl.
<script>
if (condition)
{
document.write('<HTML><HEAD><TITLE>Details Successfully Added<\/TITLE>');
document.write('<META http-equiv=\"CONTENT-LANGUAGE\" content=\"EN\">');
}
else
{
document.write("Test");
}
</script>
I've always escaped my JavaScript code writes assuming that it wouldn't work any other way. Will JS ignore the internal slashes and quotation marks, or is escaping required?