2014-02-20 41 views
1

我最初並不期望需要調用除Iframe之外的任何東西,但顯然我錯了。這裏是我的代碼,你可以看到爲什麼它打破腳本里面的腳本/腳本什麼是解決這個問題的方法?<script><script><script>無法弄清楚我該如何做到這一點

$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> 
+0

對於任何人沒有注意到即時通訊在腳本中使用腳本標記,但顯然它將第一個關閉腳本標記視爲終點。 – user3330585

+0

重複http://stackoverflow.com/questions/21896133/can-i-place-script-script-inside-script-script – Jatin

回答

0

儘管我不確定你想要完成什麼,但是你正在編織標籤,這會導致不可預知的行爲。例如,該數組元素

<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標籤的順序。

+0

嗨是啊很好發現,但多數民衆贊成,而不是我關於的問題。 – user3330585