Welcome to WebmasterWorld Guest from 54.146.240.181

Forum Moderators: open

Message Too Old, No Replies

Anything similar to EOD heredoc definitions in Javascript?

     

optik

2:16 pm on Jul 6, 2009 (gmt 0)

5+ Year Member



Hi

When defnining a variable in PHP you can avoid using slashes on every quote by using
i=<<<EOD
value
EOD;

is there anything similar in javascript or is escaping quotes the only way?

whoisgregg

7:36 pm on Jul 8, 2009 (gmt 0)

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Not in the code directly, but you could store the data in a hidden input or div and access it's value or .innerHTML (respectively) if you have a really long bit of text/html to write.

There are some hacky ways of doing it with comments, but nothing I've seen is reliable across browsers.

optik

10:21 pm on Jul 8, 2009 (gmt 0)

5+ Year Member



ok I'll probably stick with escaping quotes

DrDoc

11:06 pm on Jul 8, 2009 (gmt 0)

WebmasterWorld Senior Member drdoc is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Or, singlequote the string itself ... that way you do not have to escape all doublequotes.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month