我做了这个适用于IE10及以上版本的脚本。它也适用于Opera,Chrome,Firefox。
function trackid() {
var client = new XMLHttpRequest();
client.open('GET', 'https://radio.riddimdub.com/playing.txt');
client.onreadystatechange = function() {
var trackName = client.responseText;
document.getElementsByClassName("tracktitle")[0].innerHTML = trackName;
};
client.send()
};
trackid();
setInterval(trackid, 5000);
现在我稍微改了一下,让它适用于IE9。我这样做了:
function trackid() {
var client = new XMLHttpRequest();
client.open('GET', 'https://radio.riddimdub.com/playing.txt');
client.send()
if (client.readyState === client.DONE) {
var trackName = client.responseText;
document.getElementsByClassName("tracktitle")[0].innerHTML = trackName;
}
};
trackid();
setInterval(trackid, 5000);
问题是我在IE9上的控制台上没有出错,也没有在Opera上出错,但它在两者上都不起作用。
值得一提的是,我也尝试过:
try {
} finally {
}
我做错了什么?
答案 0 :(得分:0)
我做到了。谢谢你们的信息。以下是:
function trackid() {
var client = new XMLHttpRequest();
client.open('GET', 'https://radio.riddimdub.com/playing.txt');
client.onreadystatechange = function() {
if (client.readyState === client.DONE) {
var trackName = client.responseText;
document.getElementsByClassName("tracktitle")[0].innerHTML = trackName;
}
}
client.send()
};
trackid();
setInterval(trackid, 5000);