다음 스크립트를 사용하여 XML 문서를 구문 분석하고 웹 사이트에 표시하면이 모든 것이 효과적이지만 HTML 문서 중간에이 스크립트가 있습니다.XML 구문 분석 블로킹 페이지로드
약 300ms 내 페이지 로딩을 막아 버린 것 같습니다. 그래서이 문제를 해결하기 위해 문서 끝에 넣고 싶습니다.
내 질문은 ... 문서의 끝에이 스크립트를 어떻게 만들 수 있습니까? 문서의 중간에 출력을 표시하는 방법은 무엇입니까?
<script>
if (window.XMLHttpRequest) {
xhttp = new XMLHttpRequest();
} else {
xhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET", "abc.xml", false);
xhttp.send();
xmlDoc = xhttp.responseXML;
x = xmlDoc.getElementsByTagName("xr")[0].attributes;
att = x.getNamedItem("value");
document.write(att.value);
</script>
감사!
이 필요 로드 및 onclick보다는 오히려 나는 두려워, 나는 $ (document) .ready() 덕분에 사이트에 jquery를 사용하고 있습니다. – itezora
잠깐, 그래서 그것을 해결 했습니까? onload와 $ (document) .ready() @ user2201059? – AlvinArulselvan
아니, 나는 그것을 해결하지 못했다. 제발 그 방법 (또는 다른 onload 메서드)으로 그것을하는 방법을 보여줄 수 있다면 제발, 위대한 것입니다! :) – itezora