gpt4 book ai didi

javascript - <script> 里面 <script> 无法弄清楚我该怎么做

转载 作者:行者123 更新时间:2023-11-28 08:30:46 26 4
gpt4 key购买 nike

我最初并不期望需要调用除 Iframe 之外的任何内容,但显然我错了。这是我的代码,您可以看到为什么它破坏了脚本中的脚本-/脚本有什么方法可以解决这个问题?

$ad_blocks =
array(
array(
'<iframe data-aa="16301" src="//ad.a-ads.com/16301?size=728x90" seamless frameBorder="0" scrolling="no" style="width:728px; height:90px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></iframe>',
'<iframe data-aa="16302" src="//ad.a-ads.com/16302?size=468x60" seamless frameBorder="0" scrolling="no" style="width:468px; height:60px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></iframe>',
'<div class="A-Ads-Responsive"><iframe data-aa="16303" src="//ad.a-ads.com/16303?size=320x50" seamless frameBorder="0" scrolling="no" style="width:320px; height:50px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></div></iframe>',
),
array(
'<div><script type="text/javascript" src="http://ads1.qadabra.com/t?id=290bf071-762b-4000-9599-32f9a3daf628&size=728x90"></script></div>',
'<div><script type="text/javascript" src="http://ads1.qadabra.com/t?id=d7f3bbc3-9ef1-4558-98a1-4c8051e2dc99&size=468x60"></script></div>',
'<div class="A-Ads-Responsive"><iframe data-aa="16303" src="//ad.a-ads.com/16303?size=320x50" seamless frameBorder="0" scrolling="no" style="width:320px; height:50px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></div></iframe>',
),
);

//Get a random ad block, and store it in $rotate.
$random_key = mt_rand(0, count($ad_blocks) - 1);
$rotate = $ad_blocks[$random_key];

//These units contain the ad codes for the three sizes.
$ad_size1 = $rotate[0];
$ad_size2 = $rotate[1];
$ad_size3 = $rotate[2];
?>

<div class="col-lg-7">
<div class="A-Ads-Container">
<script>
//This function makes sure the code is executed after page is loaded.
if ($(window).width() >= 768) {
$('.col-lg-7, .A-Ads-Container').html('<?=$ad_size1?>');
} else if (($(window).width() < 800) && ($(window).width() >= 500)) {
$('.col-lg-7, .A-Ads-Container').html('<?=$ad_size2?>');
} else {
$('.col-lg-7, .A-Ads-Container').html('<?=$ad_size3?>');
}
</script>
</div>
</div>

最佳答案

虽然我不确定您到底想要完成什么,但您正在编织标签,这将导致不可预测的行为。例如这个数组元素

<div class="A-Ads-Responsive"><iframe data-aa="16303" src="//ad.a-ads.com/16303?size=320x50" seamless frameBorder="0" scrolling="no" style="width:320px; height:50px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></div></iframe>

应该是

<div class="A-Ads-Responsive"><iframe data-aa="16303" src="//ad.a-ads.com/16303?size=320x50" seamless frameBorder="0" scrolling="no" style="width:320px; height:50px; border:0px; padding:0;overflow:hidden" allowtransparency="true"></iframe></div>

注意 diviframe 结束标记的顺序。

关于javascript - &lt;script&gt; 里面 &lt;script&gt; 无法弄清楚我该怎么做,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21895813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com