部分代码
<script>
function opening(site) {
window.open(site, "newpage", "width=800;height=500");
}
window.onload = openNew;
function openNew() {
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++)
{
if (links[i].getAttribute("class") === "openNewWeb")
{
links[i].onclick = function () {
// var urll = links[i].getAttribute("href");
//opening(urll);
opening(this.getAttribute("href"));//这句和上面注释掉的两句差异在哪?为什么点击连接后该句打开了新窗口而上面两句没有?
return false;
};
}
}
}
</script>
<a class="openNewWeb" href="http://www.cctv.com/" >click here to open CCTV!</a>
<a class="openNewWeb" href="http://www.people.com.cn/" >click here to open People!</a>
磁单极