Reputation: 6350
I have to append the codes below on body
but when I am doing this onReady
, I am getting this error:
unterminated string literal
Below in code that I have appended:
jQuery('body').append('
<!--
Start of DoubleClick Floodlight Tag: Please do not remove
This tag must be placed between the <body> and </body> tags, as close as possible to the opening tag.
Creation Date: 10/12/2015
-->
<script type="text/javascript">
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write(\'<iframe src="https://338333293.fls.doubleclick.net/activityi\' + a + \'?" width="1" height="1" frameborder="0" style="display:none"></iframe>');
</script>
<noscript>
<iframe src="https://333383293.fls.doubleclick.net/activityi;src=3383293;?" width="1" height="1" frameborder="0" style="display:none"></iframe>
</noscript>
<!-- End of DoubleClick -->
');
I have done accroding to this StackOverflow Suggestion
But this is not working for me
Upvotes: 1
Views: 105
Reputation: 666
You had missed \
after </iframe>
use this and see
<script>
jQuery('body').append('
<!--
Start of DoubleClick Floodlight Tag: Please do not remove
This tag must be placed between the <body> and </body> tags, as close as possible to the opening tag.
Creation Date: 10/12/2015
-->
<script type="text/javascript">
var axel = Math.random() + "";
var a = axel * 10000000000000;
document.write(\'<iframe src="https://338333293.fls.doubleclick.net/activityi\' + a + \'?" width="1" height="1" frameborder="0" style="display:none"></iframe>\');
</script>
<noscript>
<iframe src="https://333383293.fls.doubleclick.net/activityi;src=3383293;?" width="1" height="1" frameborder="0" style="display:none"></iframe>
</noscript>
<!-- End of DoubleClick -->');
</script>
Upvotes: 0
Reputation: 3832
Your code should be
//Create Html with proper concatenation
var html='<!--Start of DoubleClick Floodlight Tag: Please do not remove This tag must be placed between the <body> and </body> tags, as close as possible to the opening tag. Creation Date: 10/12/2015-->';
html+='<script type="text/javascript">';
html+=' var axel = Math.random() + "";';
html+='var a = axel * 10000000000000;';
html+='document.write(\'<iframe src="https://338333293.fls.doubleclick.net/activityi\' + a + \'?" width="1" height="1" frameborder="0" style="display:none"></iframe>\');';
html+='</script>';
html+='<noscript>';
html+='<iframe src="https://333383293.fls.doubleclick.net/activityi;src=3383293;?" width="1" height="1" frameborder="0" style="display:none"></iframe>';
html+='</noscript>';
html+='<!-- End of DoubleClick -->';
//append html to dom
jQuery('body').append(html);
Upvotes: 0
Reputation: 36703
For this ther are multiple ways:
First:
"Hello World"
+"Yo it's amazing"
+'Yes I "Love" it';
Second: Use ``
(template)
Hello World
Yo it's amazing
Yes I "Love" it
Upvotes: 1