Exit DOM pop up window
Posted: Thu Nov 30, 2006 9:19 pm
I’m using document.createElement(“div”) and zindex to create a Javavscript DOM pop up window.
I can create the window, however I am having trouble removing it.
I have created an element in the toolbar div of the pop up window with an:
This does not do what I expected.
The closeWindow function has
The problem is that the onclick seems to fire at the point I ‘click’ to create the pop up window.
I have read up about the bubbling effect of the onclick and now I’m just confused.
I’ve not used EventListeners before and finding the whole thing a bit of a mystery.
What I want is for the DOM pop up window to open, then to be able to click on the pop up window exit/close icon in the toolbar of the pop up window to close it.
Examples on the web use HTML div id to anchor the close on or window.open, however all my divs, or more to the point, the whole pop up window is created in javascript (DOM) so it appears to be chicken and egg.
Using other methods I just get winBody has no properites or the window is not displayed, which is probably true as it has not yet been appended to the document.body before it gets 'removed' by the onclick bubbling up.
Sooo… any ideas on how to build an onclick icon into a DOM pop up window that will close it after it has been displayed.
Hope this makes sense and sorry for being so vague. I’d give you an example however nothing I’ve tried remotely works
I can create the window, however I am having trouble removing it.
I have created an element in the toolbar div of the pop up window with an:
Code: Select all
toolBar.onclick=closeWindow()
winBody.appendChild(toolBar)The closeWindow function has
Code: Select all
function closeWindow()
{
winBody.style.display=”none”;
winBody.visible=false;
}I have read up about the bubbling effect of the onclick and now I’m just confused.
I’ve not used EventListeners before and finding the whole thing a bit of a mystery.
What I want is for the DOM pop up window to open, then to be able to click on the pop up window exit/close icon in the toolbar of the pop up window to close it.
Examples on the web use HTML div id to anchor the close on or window.open, however all my divs, or more to the point, the whole pop up window is created in javascript (DOM) so it appears to be chicken and egg.
Using other methods I just get winBody has no properites or the window is not displayed, which is probably true as it has not yet been appended to the document.body before it gets 'removed' by the onclick bubbling up.
Sooo… any ideas on how to build an onclick icon into a DOM pop up window that will close it after it has been displayed.
Hope this makes sense and sorry for being so vague. I’d give you an example however nothing I’ve tried remotely works