I am trying to remotely create onclick for each div (in order to save input time). Here is the window.onload function;
window.onload = function() {
divel = document.getElementsByTagName('div');
for(var el in divel){
divel[el].onmouseover = function(){ this.style.textDecoration = "underline"; };
divel[el].onmouseout = function(){ this.style.textDecoration = "none"; };
divel[el].onclick = function(){ document.getElementById('game').src = "/games/" + this.name; };
}
}
The name of each div is "flyingsheep" - this value has been set by the traditional <div name = "flyingsheep">
When I press the div, the iframe "game" brings me to the web page "/ games / undefined"
Thanks in advance.
(Tested in Google Chrome and Fennec (not the most ordinary browsers, I know))
source
share