2016-05-14 76 views
1

我正在使用CSP並且我的Javascript傳送帶不起作用,但一切正常,但是傳送帶不起作用。 傳送帶CSS是在另一個文件中工作的,Java Script在另一個文件中也是不起作用的。啓用內容安全策略時傳送帶不起作用

我沒有收到任何錯誤。

我在做什麼錯?

提前感謝您的時間。

CSP:

<meta http-equiv="Content-Security-Policy" content="style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css; script-src 'self' https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js; script-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js">

旋轉木馬的html:

  <div class="row"> 
       <div class="col-md-12"> 
        <div class="carousel carousel-showsixmoveone slide" id="carousel123"> 
         <div class="carousel-inner"> 
          <div class="item active" ><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/1.jpg" class="img-responsive"></a></div></div> 
          <div class="item"><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/7.jpg" class="img-responsive"></a></div></div> 
          <div class="item"><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/1.jpg" class="img-responsive"></a></div></div> 
          <div class="item"><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/7.jpg" class="img-responsive"></a></div></div> 
          <div class="item"><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/2.jpg" class="img-responsive"></a></div></div> 
          <div class="item"><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/8.jpg" class="img-responsive"></a></div></div> 
          <div class="item"><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/9.jpg" class="img-responsive"></a></div></div> 
          <div class="item"><div class="col-xs-12 col-sm-4 col-md-2"><a href="#"><img src="img/bests/2.jpg" class="img-responsive"></a></div></div> 
         </div> 
         <div class="control"> 
          <a href="#carousel123" data-slide="next"><img src="css/right.png"></a> 
          &nbsp; 
          &nbsp; 
          <a href="#carousel123" data-slide="prev"><img src="css/left.png"></a> 
         </div> 
        </div> 
       </div> 
      </div> 

JavaScript文件

(function(){ 
    $('#carousel123').carousel({ interval: 2000 }); 
    $('#carouselABC').carousel({ interval: 3600 }); 
}()); 
(function(){ 
    $('.carousel-showsixmoveone .item').each(function(){ 
     var itemToClone = $(this); 
     for (var i=1;i<6;i++) { 
      itemToClone = itemToClone.next(); 
      if (!itemToClone.length) { 
       itemToClone = $(this).siblings(':first'); 
      } 
      itemToClone.children(':first-child').clone() 
      .addClass("cloneditem-"+(i)) 
      .appendTo($(this)); 
     } 
    }); 
}()); 

回答

2

代碼中不能有多個script-src 'self',所以CSP元將如下所示:

<meta http-equiv="Content-Security-Policy" content=" 
style-src 'self' https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css; 
script-src 'self' https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js">