2016-07-19 2 views
0

Chrome에서 열려고 할 때마다 HTTPS 오류로 오류가 발생하며 Chrome이 보안을 차단합니다.Javascript를 사용하여 다른 HTML 파일에 HTML 파일을 포함시키는 방법은 무엇입니까?

function w3IncludeHTML() { var z, i, a, file, xhttp; z = 
    document.getElementsByTagName("*"); for (i = 0; i < z.length; i++) 
    { 
    if (z[i].getAttribute("w3-include-html")) { 
     a = z[i].cloneNode(false); 
     file = z[i].getAttribute("w3-include-html"); 
     var xhttp = new XMLHttpRequest(); 
     xhttp.onreadystatechange = function() { 
     if (xhttp.readyState == 4 && xhttp.status == 200) { 
      a.removeAttribute("w3-include-html"); 
      a.innerHTML = xhttp.responseText; 
      z[i].parentNode.replaceChild(a, z[i]); 
      w3IncludeHTML(); 
     } 
     }  
     xhttp.open("GET", file, true); 
     xhttp.send(); 
     return; 
    } 
    } 
} 
+0

대답은 여기에서 찾을 수 있습니다 http://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file –

+0

http에서 https로 또는 그 반대로 요청할 수 없음 – charlietfl

+0

친애하는 친구에게 질문을 던지기 전에 질문하지 않았는지 물어 보았습니다. 눈을 뜨고 다시 보게하십시오. –

답변

0

나는이 라이브러리에 대한 자사의 타사 라이브러리하지만 방법을 알고

그것은 본질적으로 리메이크

https://github.com/darshanmarathe/partialjs

각도에서 NG-포함하지만 혼자 약 2킬로바이트 축소 된 서있다. 정확히 수행 할 수 있습니다 당신과 같이 요구하고 무엇을 :

<partial src="templates/header.html"></partial>` 
관련 문제