js给关键字加亮加超链接

<script language="javascript" type="text/javascript">

    var arr=     {

                    "百度":["http://www.baidu.com","#ff0000"],

                    "谷歌":["http://www.google.com","#00ff00"],

                    "雅虎":["http://www.yahoo.com","#0000ff"],

                    "网易":["http://www.163.com","#cc6600"]

            }

    document.body.innerHTML = document.body.innerHTML.replace(/(百度|谷歌|雅|虎网易)/g,function(){

                var a=arguments[0];

                return a.fontcolor(arr[a][1]).link(arr[a][0]);

            }

        );

</script>

posted @ 2011-05-02 16:50  放哨De老鼠  阅读(608)  评论(0编辑  收藏  举报