User:Meagan/DotOrg/files/mouseover.js
From 2008.igem.org
< User:Meagan | DotOrg | files(Difference between revisions)
(New page: function init() { if (document.getElementById) var x = document.getElementById('mouseovers').getElementsByTagName('IMG'); else if (document.all) var x = document.all['mouseovers'].al...) |
|||
Line 16: | Line 16: | ||
x[i].onmouseover = function () {this.src=preloads['o'+this.id].src;} | x[i].onmouseover = function () {this.src=preloads['o'+this.id].src;} | ||
x[i].onmouseout = function () {this.src=preloads['n'+this.id].src;} | x[i].onmouseout = function () {this.src=preloads['n'+this.id].src;} | ||
+ | x[i].onclick = function () {location.href=this.id + '.html'} | ||
} | } | ||
} | } |
Latest revision as of 19:07, 22 July 2008
function init() { if (document.getElementById) var x = document.getElementById('mouseovers').getElementsByTagName('IMG'); else if (document.all) var x = document.all['mouseovers'].all.tags('IMG'); else return; var preloads = new Object(); for (var i=0;i<x.length;i++) { preloads['n'+x[i].id] = new Image; preloads['n'+x[i].id].src = 'pix/'+ x[i].id + '_nrm.jpg'; preloads['o'+x[i].id] = new Image; preloads['o'+x[i].id].src = 'pix/'+ x[i].id + '_omo.jpg'; preloads['o'+x[i].id].onerror = function () {this.src='pix/default.gif'} x[i].onmouseover = function () {this.src=preloads['o'+this.id].src;} x[i].onmouseout = function () {this.src=preloads['n'+this.id].src;} x[i].onclick = function () {location.href=this.id + '.html'} } }