<!DOCTYPE html> <html> <head> <script>
function loadXMLDoc(url) {
var xmlhttp;
var txt, x, xx, i;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
txt = "<table border='1'><tr><th>Title</th><th>Artist</th></tr>";
x = xmlhttp.responseXML.documentElement.getElementsByTagName("curriculum_item");
for (i = 0; i < x.length; i++) {
txt = txt + "<tr>";
xx = x[i].getElementsByTagName("title");
{
try {
txt = txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er) {
txt = txt + "<td> </td>";
}
}
xx = x[i].getElementsByTagName("abstract");
{
try {
txt = txt + "<td>" + xx[0].firstChild.nodeValue + "</td>";
}
catch (er) {
txt = txt + "<td> </td>";
}
}
txt = txt + "</tr>";
}
txt = txt + "</table>";
document.getElementById('txtCDInfo').innerHTML = txt;
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
} </script> </head> <body>
<div id="txtCDInfo"> <button onclick="loadXMLDoc('curriculum_materials.xml')">Get CD info</button> </div>
</body> </html>
こんにちは、みんな、
ファイルから読み取り、html5 ページにコンテンツを表示する html5 ページを作成する必要があります。Visual Studioで実行すると、これは正常に機能します。
しかし、これらを他のフォルダーにコピーしてそこから実行すると、ほとんどのブラウザーでは機能しません。IE 9、firefox、chrome で試してみました。CDを挿入すると自動実行されるように、これをCDに書き込む必要があります。上記のコードを見つけてください。多くの人が同じ質問をしていることは知っていますが、これに対する解決策を見つけることができませんでした.