How do I embed verbatim javascript without interpreting it?
I have a formatted text area with the following:
"<p align=left><script>alert('what's new\");</script> - 1</p>"
which comes out in the document as:
alert('what's new"); - 1
The script tags have been stripped away, but I want the verbatim text without interpretation
Verbatim Javascript
Re: Verbatim Javascript
Support · Aug 7, 2008Hello,
It is not possible to add the java script along with the formatted text using the FormattedTextArea page element. The script tag is not supported by this page element. You can refer to the supported HTML tags
in our help documentation.
You can add the java script to the PDF document by using the DocumentJavaScript object. You may have to use this object. You can refer to the JavaScript
topic on our help documentation.
Thanks,
ceTe Software Support Team.
Re: Verbatim Javascript
Forum member · Aug 7, 2008I'm not sure that you understand the issue. I don't want the text treated as Javascript, I just want it to be text. So if it is NOT a recognized tag, I want to ignore it and leave it there, not strip it out.
Re: Verbatim Javascript
Support · Aug 7, 2008Hello,
We will check with the developers on this behavior and we will post a message as soon as we here something from them.
Thanks,
ceTe Software Support Team.
Re: Verbatim Javascript
Forum member · Aug 7, 2008By the way, even if I html encode the text, it strips out the tags in a strange way --
"<script>alert('hello');</script>"
becomes
<alert('hello');<
Re: Verbatim Javascript
Support · Aug 7, 2008Hello,
In order to display the < and > symbols you can use the < and >. The string "<script>alert('hello');</script>" in the FormattedTextArea gives the desired result.
Thanks,
ceTe Software Support Team.
Re: Verbatim Javascript
Support · Aug 7, 2008Hello,
You will have to use the & l t ; (without sapces) in order to display the < symbol. In the previous forum message this was shown as <. You will have to use the & g t ; for displaying the > symbol.
Thanks,
ceTe Software Support Team.
Re: Verbatim Javascript
Forum member · Aug 7, 2008Ah, it looks like I had the same problem in my previous post as well. What I pasted as & l t ; showed up as <.
But anyway, it looks like it was a strange combination of events that caused the issue.
I created the FormattedTextArea with the text "& l t ;script& g t ;alert('hello');& l t ;/script& g t ;"
Then I set the Height: myArea.Height = myArea.GetRequiredHeight();
After that, if you look at the text it becomes:
"& l t<script& g t>alert('hello');& l t</script& g t >"
(in case this doesn't appear correctyly, the & l t ; became & l t <
Then in my code, I did the following:
myArea.Text = "<p " + alignText.ToString() + ">" + myArea.Text + "</p>";
Since the text was now bad after setting the height, the results were incorrect.
If I move setting the Height to the end, it still has a strange effect on the text ("& l t ;" becomes "& l t <" -- removing spaces), but it appears to display correctly in the PDF.
Thanks,
Leslie