附加具有多个单引号的代码

时间:2022-10-28 15:43:12

I have to append the codes below on body but when I am doing this onReady, I am getting this error:

我必须将下面的代码附加到正文上,但是当我在onReady上执行此操作时,我收到此错误:

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 * Suggestion

我已经完成了这个*建议

But this is not working for me

但这不适合我

3 个解决方案

#1


0  

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);

#2


1  

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

你好世界哟这太棒了我是“喜欢”它

#3


0  

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>

#1


0  

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);

#2


1  

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

你好世界哟这太棒了我是“喜欢”它

#3


0  

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>