function externallinks() { 
 if (!document.getElementsByTagName) return; 
 var anchors = document.getElementsByTagName("a"); 
 for (var i=0; i<anchors.length; i++) { 
   var anchor = anchors[i]; 
   if (anchor.getAttribute("href") && 
       anchor.getAttribute("rel") == "external") 
     anchor.target = "_blank"; 
 } 
} 
window.onload = externallinks;

window.onload = function() {
    //遍历文档中的图片
    for (var index = 0; index < document.images.length; index++) {
        //定义要限制的图片宽高
        var widthRestriction = 360;
        var heightRestriction = 300;
        //开始调整尺寸
        if (document.images[index].width > widthRestriction) {
            document.images[index].width = widthRestriction;
        } else if (document.images[index].height > heightRestriction) {
             document.images[index].height = heightRestriction;
        }
        //注册事件，点击在新窗口打开原图
        document.images[index].onclick = function() {window.open(this.src)};
        document.images[index].title = document.images[index].title + ' 点击在新窗口中查看原图';
    }
}