<script>
document.getElementById("aaa").onclick = function{window.open(document.getElementById("aaa").src,'','');}
</script>
document.getElementById("aaa").onclick = function{window.open(document.getElementById("aaa").src,'','');}
</script>
function addHref(element)//参数就是img的实例
{
var link = document.createElement("a");
link.href = element.src;
element.parentNode.insertBefore(link,element);
link.appendChile(element);
}
//以你上面的HTML做例子
addHref(document.getElementById("aaa"));
2楼的错了个字母哦,应该是appendChild,我说怎么测试了下不对,还好有百度。
结贴