diff --git a/lib/OpenLayers/Popup.js b/lib/OpenLayers/Popup.js index 0c5cccbaa8..ecd2a1f61d 100644 --- a/lib/OpenLayers/Popup.js +++ b/lib/OpenLayers/Popup.js @@ -785,10 +785,13 @@ OpenLayers.Popup = OpenLayers.Class({ //use cached value if we have it var contentDivPadding = this._contentDivPadding; if (!contentDivPadding) { - //make the div invisible and add it to the page - this.div.style.display = "none"; - document.body.appendChild(this.div); - + + if (this.div.parentNode == null) { + //make the div invisible and add it to the page + this.div.style.display = "none"; + document.body.appendChild(this.div); + } + //read the padding settings from css, put them in an OL.Bounds contentDivPadding = new OpenLayers.Bounds( OpenLayers.Element.getStyle(this.contentDiv, "padding-left"), @@ -799,10 +802,12 @@ OpenLayers.Popup = OpenLayers.Class({ //cache the value this._contentDivPadding = contentDivPadding; - - //remove the div from the page and make it visible again - document.body.removeChild(this.div); - this.div.style.display = ""; + + if (this.div.parentNode == document.body) { + //remove the div from the page and make it visible again + document.body.removeChild(this.div); + this.div.style.display = ""; + } } return contentDivPadding; },