Here is the code:
for (i = 0; i < 8; i++) {
var meun = document.createElement("div");
meun.setAttribute('id', i);
meun.setAttribute("style", "width:70px; height:70px; background:url(archive/" + i + ".jpg); background-size: 70px 70px; float:left; margin-top:10px; opacity:1");
document.body.appendChild(frame);
document.getElementById("frame").appendChild(meun);
meun.addEventListener('click', function () {
window.location.href = "i+'.html'"
}, false);
}
The problem I have is in addEventListener: how to pass the variable i into the href? I guess it is a problem of syntax.
Not only a syntax problem, you also need a closure: