这个代码没有实现,请大神指点一二,想法是浏览过的网页在visted里是红色的,未浏览的网页在notvisted里
<html>
<body>
<H3>visited</H3>
<ul id="visited"></ul>
<H3>Not Visited</H3>
<ul id="notvisited"></ul>
<script>
var websites = [
"http://www.qq.com/",
"http://www.baidu.com/",
"http://www.qq.com/",
"http://www.google.com/",
"http://www.sohu.com/",
"http://zhidao.baidu.com/",
];
for (var i = 0; i < websites.length; i++) {
var link = document.createElement("a");
link.id="id" + i;
link.href = websites[i]
link.innerHTML = websites[i];
document.write('<style>');
document.write('#id' + i + ":visited {color: #FF0000;}");
document.write('</style>');
document.body.appendChild(link);
var color = document.defaultView.getComputedStyle(link,null).getPropertyValue("color");
document.body.removwChild(link);
if (color == "rgb(255,0,0)") {
var item = document.createElement('li');
item.appendChild(link);
document.getElementById('visited').appendChild(item);
} else {
var item = document.createElement('li');
item.appendChild(link);
document.getElementById('notvisited').appendChild(item);
}
}
</script>
</body>
</html>
好苦恼讶