2017-11-08 3 views
-1

현재 Tumblr의 테마 작성기 프레임 워크에서 작업 중이며 특정 스크립트를 외부 리소스로 업로드하는 데 어려움을 겪고 있습니다. 여러 번의 업로드 시도가있을 때마다 Tumblr은 업로드하려고하는 파일이 .js 파일인데도 자산으로 업로드 할 .html 파일을 허용하지 않는다는 오류 메시지가 지속적으로 나타납니다.누군가이 스크립트를 외부 리소스로 업로드 할 수없는 이유를 설명 할 수 있습니까?

내 사이트가 HTTPS를 통해 실행된다는 점에 주목할 필요가 있습니다. 그러면 아래 코드와 같이 외부 소스/자산으로로드 할 수없는 코드는 무엇입니까?

UPDATE :

if (photos[j].alt_sizes[1]) { 
     imgURL = photos[j].alt_sizes[1].url; 
     // console.log(imgURL, linkURL); 
     } else { 
     continue; 
     } 
     $("#tumblr-posts").append(
     "<li><a href=" + 
      linkURL + 
      "><img src=" + 
      imgURL + 
      " /></a>" + 
      "</li>" 
    ); 
    } 

거부 ​​된 외부 JS (mycustomscript.js) :

apiKey = "API-HIDDEN"; 
limit = 4; 
$.ajax({ 
    url: "https://api.tumblr.com/v2/blog/MYTUMBLRID.tumblr.com/posts?limit=4", 
    dataType: "jsonp", 
    data: { 
    api_key: apiKey, 
    tag: "blog" 
    }, 
    success: function(results) { 
    var i = 0; 
    while (i < results.response.posts.length) { 
     var type = results.response.posts[i].type; 
     if (type == "photo") { 
     var photos = results.response.posts[i].photos; 
     var linkURL = results.response.posts[i].post_url; 
     var caption = results.response.posts[i].caption; 
     for (var j = 0; j < photos.length; j++) { 
      if (photos[j].alt_sizes[1]) { 
      imgURL = photos[j].alt_sizes[1].url; 
      // console.log(imgURL, linkURL); 
      } else { 
      continue; 
      } 
      $("#tumblr-posts").append(
      "<li><a href=" + 
       linkURL + 
       "><img src=" + 
       imgURL + 
       " /></a>" + 
       "</li>" 
     ); 
     } 
     } 
     i++; 
    } 
    console.log(results.response); 
    } 
}); 

얼마나 좋아, 지금까지 문제가 스크립트에서 HTML의이 부분 함께 할 수있는 뭔가가 스크립트를 호출하려고 시도했습니다 (숨겨진 링크 부분을 숨기기위한 x 위치).

<script src="http://static.tumblr.com/x/x/mycustomscript.js"></script> 
+1

디버깅 시도로, 해당 파일 (추가)에서 모든 html을 제거하십시오. –

+1

'http : //'를'// '로 바꾸십시오. AFAIK, 보안 사이트 내의 비보안 위치의 스크립트를로드 할 수 없습니다. –

+0

@KevinB, 고마워. 이것은 분명히 스크립트에서 HTML에 문제가 있다는 것을 증명했습니다 ... – nr159

답변

0

스크립트의 HTML 태그 당신은

"<li>" 

있도록 HTML 태그를 분할하여이 문제를 해결할 수

"<"+"li>" 

가되어 너무 끝 태그와 동일한 작업을 수행.

관련 문제