0

I'm currently using a javascript product called prototip

Their default setup is the following

<script type="text/javascript" language="javascript">
new Tip('test_style', 'Text for tooltip goes here', {
title: 'Title Goes Here',
style: 'protogrey'
});
</script>

I'm currently looking to add a table of sorts within my tooltip but for some reason when I add the table in to the text for the tooltip it will never display.

I have tried swapping the ' to " thinking it might be conflicting, I've also tried escaping the closing tags of the table to no avail. I just wanted to know with the current setup above if it would even be possible to do.

<script type="text/javascript" language="javascript">
new Tip('test_style', '<table><tr>
<td width="84">Test</td>
<td width="100">Test</td>
</tr></table>', {
title: 'Test',
style: 'protogrey'
});
</script>

Thanks

6
  • Have you tried removing the newlines in the markup section? i.e. <table><tr><td width="84">....? JavaScript often has issues with strings going off to a new line. Commented Mar 2, 2013 at 15:11
  • 1
    JavaScript does not support multi-line string literals. Commented Mar 2, 2013 at 15:11
  • Hmm that is actually something that past my mind - Ill try that now Commented Mar 2, 2013 at 15:11
  • Worked perfectly /facepalm Commented Mar 2, 2013 at 15:13
  • 1
    you can also use the "\" character at the end of every line but the last, to keep using multiline strings. Commented Mar 2, 2013 at 15:17

1 Answer 1

1

If your going to put the html into a sting and use multiple lines you have to escape the white space.

var html = '\
<h1>\
Hello\
</h1>';
Sign up to request clarification or add additional context in comments.

1 Comment

But of course, this isn't part of the spec, so the fact browsers support it can't be assumed. From bclary.com/2004/11/07/#a-7.8.4: "A 'LineTerminator' character cannot appear in a string literal, even if preceded by a backslash \."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.