测试:
http://www.etherdream.com/FunnyScript/CheckVisted/Demo.html
效果很有趣,原理很简单,源码里都说了。临时性的方法,期待更完美的解决方案<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>看看你上过哪些网站</title>
</head>
<body>
<style>
.box
{
position: absolute;
left: -999px;
width: 30px;
height: 30px;
overflow: scroll;
visibility: hidden;
}a{font-size: 10px}
a:visited{font-size: 60px}
</style>
<script>
/**
 * history url detect
 *   by etherdream
 */
var $c = function(t){return document.createElement(t)};/*
 * 函数:hasVisted
 * 参数:url
 * 说明:检测最近是否访问过这个url
 * 原理:<a href='URL'>X</a>
 *       如果访问过这个url,
 *       那么a:visited 样式将被使用在此元素上。
 *       通过脚本检测该样式产生的影响,
 *       即可判断是否访问过。
 *
 *       本例通过设置超大字体,
 *       检测外层元素的滚动条来判定。
 *       相信有更好的方法。
 */
function hasVisted(url)
{
var div = $c("div");
var lnk = $c("a");
var h; div.className = "box";
lnk.href = url;
lnk.innerHTML = "X"; div.appendChild(lnk);
document.body.appendChild(div); h = div.scrollHeight; div.removeChild(lnk);
document.body.removeChild(div); return h > 30;
}
</script><p>你最近浏览过:</p><script>
var demo = [
"http://www.google.com",
"http://www.baidu.com",
"http://tieba.baidu.com",
"http://hi.baidu.com",
"http://www.qq.com",
"http://qzone.qq.com",
"http://www.163.com",
"http://www.sina.com",
"http://www.sohu.com",
"http://www.cnblogs.com",
"http://www.csdn.com",
"http://bbs.blueidea.com"
];var url;
for(var i=0; i<demo.length; i++)
{
url = demo[i];
if(hasVisted(url))
document.write("<img src='" + url + "/favicon.ico' /> " + url + "<br />");
}</script>
</body>
</html>

解决方案 »

  1.   

    我天天主要泡在CSDN上,偶尔看看我Gmail和163的邮箱。或者到我博客园上面写些技术blog,或者MS的Spaces上面写点影评什么的。找东西我就baidu,不去google。偶尔看看JavaEye,别的网站我也不知道什么了。
      

  2.   

    改进版<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>看看你上过哪些网站</title>
    </head>
    <body>
    <style>
    a{display:none}
    a:visited{display:none; font-size:60px}
    </style>
    <script>
    function hasVisted(url)
    {
    var lnk = document.createElement("a"); lnk.href = url;
    document.body.appendChild(lnk); try{
    sty = lnk.currentStyle || getComputedStyle(lnk, null);
    return sty.fontSize == "60px";
    }
    catch(e){}
    finally{
    document.body.removeChild(lnk);
    }
    }
    </script><p>你最近浏览过:</p><script>
    var demo = [
    "http://www.google.com",
    "http://www.baidu.com",
    "http://tieba.baidu.com",
    "http://hi.baidu.com",
    "http://www.qq.com",
    "http://qzone.qq.com",
    "http://www.163.com",
    "http://www.sina.com",
    "http://www.sohu.com",
    "http://www.cnblogs.com",
    "http://www.csdn.com",
    "http://bbs.blueidea.com"
    ];var url;
    for(var i=0; i<demo.length; i++)
    {
    url = demo[i];
    if(hasVisted(url))
    document.write("<img src='" + url + "/favicon.ico' /> " + url + "<br />");
    }
    </script>
    </body>
    </html>
      

  3.   

    用currentStyle(IE,Op,)和getComputedStyle(Fx)可以直接获取最终的CSS样式对象,即经过计算后最终显示在浏览器里的样式。还有个可以大幅优化的地方就是不用每次createElement和removeChild,不过貌似IE不支持。我再继续研究研究。
      

  4.   

    GOOD!!!!期待更完美的!!!!
      

  5.   

    多谢!不过ie里直接修改a的href属性,貌似a:visted不会立即应用上去。但也没关系,这样已经够简单了!!!
      

  6.   

     http://www.google.com
    http://www.baidu.com
    http://tieba.baidu.com
    http://www.sina.com
      

  7.   

    csdn.com 应该改为 csdn.net
      

  8.   

    在 Safari 浏览器中似乎没有用。
      

  9.   

    访问过的地址链接scrollHeight、fontSize 和没访问的大小不一样???只能具体到某个链接,清除ie历史后,访问http://community.csdn.net/HomePage.aspx,是不会显示访问过http://community.csdn.net不过LZ的这个小技巧也不错。
      

  10.   

    var demo = [
        "http://www.google.com",
        "http://www.baidu.com",
        "http://tieba.baidu.com",
        "http://hi.baidu.com",
        "http://www.qq.com",
        "http://qzone.qq.com",
        "http://www.163.com",
        "http://www.sina.com",
        "http://www.sohu.com",
        "http://www.cnblogs.com",
        "http://www.csdn.com",
        "http://bbs.blueidea.com"
    ]; 
      

  11.   

    chrome a:visited不支持改变font-size只支持color
      

  12.   

    你最近浏览过: http://www.163.com
     http://community.csdn.net