By in JavaScript, do you mean that the content MUST be inside a
JavaScript file? Or just that the content must be accessible from
JavaScript?

My preferred method is to have the content in a separate place, and
reference it via the JavaScript. My preferred "separate place" for
HTML templates would be this trick in the HTML of the page:

<script type="html/template" id="template_1">
<p>Any <span>manner</span>
     <ol><li>of</li></ol>
     markup "necessary" for you're stuff.
</p>
</script>

...
later, in your js:

var my_html = $("#template_1").text();


This solves you needing to do escaping on your content. The only kind
of markup that can't be in your template (without escaping) is of
course and ending </script> tag as that would close the template.

--Kyle




On Jun 29, 11:48 am, Lorin Rivers <[email protected]> wrote:
> What would the best method for making an arbitrary chunk of html (likely to 
> include the dreaded single & double quote characters as well as tags, so / 
> will be \/) in a JavaScript?
>
> I think the term is escaping, but basically making a short <p> JavaScript 
> safe. The environment is WordPress and probably Prototype but possibly JQuery.
>
> See:http://wheco.com/company/news/
>
> Thanks!
> --
> Lorin Rivers
> Mosasaur: Killer Technical Marketing <http://www.mosasaur.com>
> <mailto:[email protected]>
> 512/203.3198 (m)

-- 
Our Web site: http://www.RefreshAustin.org/

You received this message because you are subscribed to the Google Groups 
"Refresh Austin" group.

[ Posting ]
To post to this group, send email to [email protected]
Job-related postings should follow http://tr.im/refreshaustinjobspolicy
We do not accept job posts from recruiters.

[ Unsubscribe ]
To unsubscribe from this group, send email to 
[email protected]

[ More Info ]
For more options, visit this group at 
http://groups.google.com/group/Refresh-Austin

Reply via email to