Napisałem skrypt, który tworzy okienko niestety nie mogę sprawić, aby po kliknięciu na obrazek okienko było usuwane.
var iCurrent = 0;
function QuePopUp(sText, bLock) {
bodyWidth = document.body.offsetWidth;
bodyHeight = document.body.offsetHeight;
var div = document.createElement('div');
if(bLock) {
div.setAttribute('id', 'QuePopUp' + iCurrent);
div.setAttribute('class', 'QuePopUp');
var sContent = document.createTextNode(sText);
var img = document.createElement('img');
img.setAttribute('onClick', 'QuePopUp(null, false)');
img.setAttribute('src', 'close_pop.png');
img.setAttribute('style', 'top:-30px; left:-60px;');
div.appendChild(sContent);
document.body.appendChild(div);
document.getElementById('QuePopUp' + iCurrent).appendChild(img);
iCurrent++;
} else {
document.getElementById("QuePopUp" + iCurrent).removeChild(document.getElementById("QuePopUp" + iCurrent).lastChild);
}
}
Błąd: document.getElementById("QuePopUp" + iCurrent) is null
Wiersz: 25
[EDIT]
Problem został rozwiązany:
var iCurrent = 0;
function QuePopUp(sText, bLock) {
bodyWidth = document.body.offsetWidth;
bodyHeight = document.body.offsetHeight;
var div = document.createElement('div');
if(bLock) {
div.setAttribute('id', 'QuePopUp' + iCurrent);
div.setAttribute('class', 'QuePopUp');
div.style.display = 'block';
var sContent = document.createTextNode(sText);
var img = document.createElement('img');
img.setAttribute('onClick', 'QuePopUp(null, false)');
img.setAttribute('src', 'close_pop.png');
img.setAttribute('style', 'top:-30px; left:-60px;');
div.appendChild(sContent);
document.body.appendChild(div);
document.getElementById('QuePopUp' + iCurrent).appendChild(img);
iCurrent++;
} else {
document.body.removeChild(document.body.lastChild);
}
}