Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 具有多个单引号的追加代码_Javascript_Jquery - Fatal编程技术网

Javascript 具有多个单引号的追加代码

Javascript 具有多个单引号的追加代码,javascript,jquery,Javascript,Jquery,我必须将下面的代码附加到正文中,但当我在onReady上执行此操作时,出现以下错误: 未终止字符串文字 下面是我附加的代码: jQuery('body').append(' <!-- Start of DoubleClick Floodlight Tag: Please do not remove This tag must be placed between the <body> and </body> tags, as c

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

未终止字符串文字

下面是我附加的代码:

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  -->
');
jQuery('body')。append('
var axel=Math.random()+“”;
var a=axel*100000000000;
文件。写入(\“”);
');
我已经完成了这项工作


但这对我不起作用

为此,有多种方法:

第一名:

"Hello World"
+"Yo it's amazing"
+'Yes I "Love" it';
秒:使用
`
(模板)

你好,世界
哟,太神奇了
是的,我“喜欢”它

你的代码应该是

//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);
//使用适当的连接创建Html
var html='';
html+='';
html++=“var axel=Math.random()+”“;”;
html+='var a=axel*1000000000000;';
html+=“document.write(\'\');”;
html+='';
html+='';
html+='';
html+='';
html+='';
//将html附加到dom
jQuery('body').append(html);

用这个看看

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

jQuery('body')。append('body')
var axel=Math.random()+“”;
var a=axel*100000000000;
文件。写(\'\');
');

我认为您的html正在崩溃。请用alert()检查;你应该为此创建提琴,这样任何人都可以帮助你处理html中断be
\')是否也在代码中添加了换行符,或者为了清晰起见在此处添加了换行符?因为它们不应该出现在你的代码中。@Rajesh我已经这样做了,但事实并非如此working@Gaurav你检查过了吗?@Gaurav people和
标记注释。你可以从另一个文件加载此html,这样它们就不会被破坏$(“div”).load(“s1.html”);