Welcome to WebmasterWorld Guest from 54.221.165.245

Forum Moderators: open

Message Too Old, No Replies

Anything similar to EOD heredoc definitions in Javascript?

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

Full Member

5+ Year Member

joined:Aug 17, 2007
posts:320
votes: 0


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?

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

Senior Member

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

joined:Dec 9, 2003
posts:3416
votes: 0


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.

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

Full Member

5+ Year Member

joined:Aug 17, 2007
posts:320
votes: 0


ok I'll probably stick with escaping quotes
11:06 pm on July 8, 2009 (gmt 0)

Senior Member

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

joined:Mar 15, 2002
posts:6807
votes: 0


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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members