2014-01-29 2 views
0

저는 초보자이며 자바 스크립트에 대해 많이 알지 못합니다. 내가 아는 전부는 사파리와 익스플로러에서는 다음 페이지/코드가로드되지만 크롬이나 파이어 폭스에서는 그렇지 않다. 누구든지 누락 된 코드 나 특정 오류를 지적 할 수 있습니까? 매우 감사. 여기에 실제 페이지입니다 : https://dl.dropboxusercontent.com/u/9832487/Timeline/timeline2.html크롬 또는 Firefox에서 Javascript가 작동하지 않습니다.

<!DOCTYPE html> 
<html> 
    <head> 
     <meta charset="UTF-8" /> 
     <link REL="SHORTCUT ICON" HREF="UVALogo.ico"> 
      <title>SS Timeline Tool</title> 
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> 
      <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 
      <style type="text/css"> 
      body { font-family:Verdana,Geneva,sans-serif; font-size:xx-small; } 
      .rounded-corners { -moz-border-radius:8px;-webkit-border-radius:8px;-khtml-border-radius:8px;border-radius:8px;} 
      .shadedback { background-color:#eee;border-radius:8px; 
       background:-moz-linear-gradient(top,#f0f0f0,#dfdfdf); 
       background:-webkit-linear-gradient(top, #f0f0f0 0%, #dfdfdf 100%); 
       border-collapse: collapse; 
       } 
      </style> 
</head> 

     <body> 
      <div id="surfaceDiv" style="position:absolute;left:29%;width:68%;padding:1%" class="rounded-corners"></div> 
      <div id="picBinDiv" style="position:absolute;left:1%;width:25%;padding:1%" class="shadedback"></div>    

     </body> 
    </html> 

    <script> 

    // SETUP 

    var picWidth=0;             // Width of pics (use 0 to disable) 
    var picHeight=96;            // Height of pics(use 0 to disable) 
    var backPic="background.jpg";             // URL to back surface picture (if any) 
      var pics=["https://dl.dropboxusercontent.com/u/9832487/Timeline/Images/cch.jpg",   // Each entry in array is a pic 
    ]; 





    // ON LOAD 

    $(document).ready(function() {         // When document is loaded 
     var height=$(window).height();        // Get height of window 
     height=height*.9;           // Fill only 90% of window 
     height=height+"px";           // Add pixel suffix 
     $("#picBinDiv").css("height",height);      // Set picBin height 
     $("#surfaceDiv").css("height",height);      // Set surface height 
     AddPics(pics);            // Add pics to pic bin 
     if (backPic)            // If a background pic spec'd 
     {$("#surfaceDiv").append("<img src='"+backPic+"' height='"+height+"'/>");} // Add pic to div 
     else              // No back 
     {$("#surfaceDiv").css("border","1px solid #999");}  // Add border 
     }); 

    // ADD PICS 

    function AddPics(picArray)         // ADD PICS TO PIC BIN 
{ 
    var i,picHtml; 
    var n=picArray.length;          // Number of pics to load 
    for (var i=0;i<n;++i) {          // For each pic to load 
    picHtml="<img src='"+picArray[i]+"' ";     // Add tag and url 
    picHtml+="id='pic"+i+"' ";        // Add id 
    if (picHeight)           // If height spec'd 
    picHtml+="height='"+picHeight+"px'";    // Scale by height 
    else if (picWidth)          // If a width spec'd 
    picHtml+="width='"+picWidth+"px'";     // Scale by width 
    picHtml+="> ";           // Add close tag and space 
    $("#picBinDiv").append(picHtml);      // Add pic to div 
    $("#pic"+i).draggable();        // Make it draggable 
    } 

    } 

    </script> 

답변

1

당신은 자바 스크립트에 HTTP를 사용하고 있지만, 사이트는 HTTPS (혼합 컨텐츠)에 있습니다. 그래서 기본적으로 chrome과 firefox는 그것을 차단합니다.

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 

또 하나 개의 솔루션은 보관 자체에 JQuery와 및 jqueryui 파일을 넣고 상대 링크를 제공하는 것입니다 : 당신은 내가 아래 JQuery와의 URL을 변경 다른 이미지에 표시되는 방법으로 차단을 해제해야합니다 .

검사 기존 코드로 차단을 해제하려면 아래 이미지

enter image description here

1

당신이있는 거 사이트 (https)를 확보하지만, 안전하지 않은 (http) 호출되는 스크립트입니다 :

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 

그래서 Chrome과 FF는 mixed content으로 간주되어 스크립트가 실행되는 것을 차단합니다. 당신이 제공하는 경우 그 스크립트의 보안 버전은 작동합니다 파일 :

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> 
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script> 
0

아직 브라우저에서 코드를 확인하지 않았하지만 첫번째보기에서 내가 머리에 태그를 닫아야합니다 생각합니다. 또한 현재 내부에없는 JavaScript 부분 태그를 이동해야합니다. 문제가 해결 될 것이라고 생각합니다. 크롬 콘솔을 사용하여 오류가 발생하는지 확인해야합니다. 크롬에서 자바 스크립트 콘텐츠를 구문 분석 할 수 있는지 확인하려면 console.log() 또는 alert() 문을 사용해야합니다.

관련 문제