Consider the following code:
index.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="script.js"></script>
</head>
<body>
<form>
<button id="getInfoButton1"></button>
<input type="button" id="getInfoButton2"></input>
</form>
</body>
</html>
With the accompanying JavaScript file:
script.js
window.onload = initAll;
var req;
function initAll()
{
document.getElementById("getInfoButton1").onclick = getInfo;
document.getElementById("getInfoButton2").onclick = getInfo;
}
function getInfo()
{
req = new XMLHttpRequest();
var URL = "index.html";
req.open("GET", URL, true);
req.onreadystatechange = whatsTheStatus;
req.send(null);
}
function whatsTheStatus()
{
if (req.readyState != 4) { return; }
alert(req.status);
}
(I greatly reduced my code, but this example still emphasizes the error)
The question arises: When you download it and press both buttons, the first displays the status 0, and the second displays the status 200.
Of course, I expect both to display 200, and I have no idea why it <button>behaves differently. This is not a terribly big deal, but I would like to maintain the same use <button>on my site.
I looked at the website and asked some other developers in my company, and we can not find the answer. Any ideas?
, Firefox 3.6.8. , localhost WAMPserver 2.0.