<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<script type="text/javascript">
function parseXML(name) {
try //Internet Explorer
{ xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); }
catch (e) {
try
//Firefox, Mozilla, Opera, etc.
{ xmlDoc = document.implementation.createDocument("", "", null); }
catch (e) { alert(e.message); return; }
}
xmlDoc.async = false;
xmlDoc.load(name);
document.getElementById("to").innerHTML = xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML = xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML = xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
}
function test(name) {
alert(name);
}
var name="note.xml";
</script>
</head>
<body οnlοad="parseXML(name);">
<h1>
W3Schools Internal Note</h1>
<p>
<b>To:</b> <span id="to"></span>
<br />
<b>From:</b> <span id="from"></span>
<br />
<b>Message:</b> <span id="message"></span>
</p>
<input type ="button" value ="button" onclick ="test("note.xml");" />
</body>
</html>
错误处:<input type ="button" value ="button" onclick ="test("note.xml");" />
传递参数应该为单引号:<input type ="button" value ="button" onclick ="test(’note.xml‘);" />
愚蠢的错误 ,,又是标点惹的祸。