O
OttoA
Hello,
I was creating a transparent cover-div for my interactive content to
prevent the user clicking all kinds of trouble during xhr-loads, when
I discdovered that IE (at least 6 and 7) did something unexpected. My
idea was to hang on to the cover-div once it's created, and then to
remove it/place it over the content as needed. As I was checking its
in place/removed status only by looking at the existence of the cover-
div's DOM-object's parentNode I found that after a
coverdiv.parentNode.removeChild(coverdiv)-operation the coverdiv,
instead of having null for its parentNode, had a documentFragment for
a parent.
I was expecting it to be null, and later found that at least David
Flanagan's book concurred, as did the other browsers.
Now obviously this is not a hard thing to remedy, I'm just curious
whether this is a known issue (perhaps a feature?) and to check that
I'm not just missing something obvious. The test code below worked
fine in (windows versions of) FF 3, Chrome and Opera 9 (except for the
transparency in Opera, but that's a different matter). I couldn't find
any references to this in msdn, Quirksmode, or by general googling, so
at least it doesn't seem to be documented.
Thanks in advance for any comments/suggestions etc.
-OP
and the code:
<html><head>
<script type="text/javascript">
var Glob = {};
function toggle() {
if(!Glob.d) {
Glob.d = document.createElement("div");
Glob.d.className = "trans";
}
alert("Glob.d's parent before: "+
(Glob.d.parentNode ?
Glob.d.parentNode.nodeName : Glob.d.parentNode)
);
if(Glob.d.parentNode){ Glob.d.parentNode.removeChild(Glob.d); }
else{ document.body.appendChild(Glob.d); }
alert("Glob.d's parent after: "+
(Glob.d.parentNode ?
Glob.d.parentNode.nodeName : Glob.d.parentNode)
);
}
</script>
<style type="text/css">
div.trans {
background-color: #FFF;
filter: progidXImageTransform.Microsoft.Alpha(opacity=30);
background: rgba(255,255,255,0.3);
position: absolute;
width: 700px;
height: 400px;
border: 1px solid black;
z-index: 99;
top: 40px;
}
</style>
</head>
<body>
<button onclick="toggle()">toggle</button>
<div>
<p>Test content, should be covered by a transparent cover div.</p>
<p>This will make all content unreachable to mouseclicks, such as <a
href="www.google.com">links to places</a>.</p>
<p>Final paragraph of text.</p>
</div>
</body></html>
I was creating a transparent cover-div for my interactive content to
prevent the user clicking all kinds of trouble during xhr-loads, when
I discdovered that IE (at least 6 and 7) did something unexpected. My
idea was to hang on to the cover-div once it's created, and then to
remove it/place it over the content as needed. As I was checking its
in place/removed status only by looking at the existence of the cover-
div's DOM-object's parentNode I found that after a
coverdiv.parentNode.removeChild(coverdiv)-operation the coverdiv,
instead of having null for its parentNode, had a documentFragment for
a parent.
I was expecting it to be null, and later found that at least David
Flanagan's book concurred, as did the other browsers.
Now obviously this is not a hard thing to remedy, I'm just curious
whether this is a known issue (perhaps a feature?) and to check that
I'm not just missing something obvious. The test code below worked
fine in (windows versions of) FF 3, Chrome and Opera 9 (except for the
transparency in Opera, but that's a different matter). I couldn't find
any references to this in msdn, Quirksmode, or by general googling, so
at least it doesn't seem to be documented.
Thanks in advance for any comments/suggestions etc.
-OP
and the code:
<html><head>
<script type="text/javascript">
var Glob = {};
function toggle() {
if(!Glob.d) {
Glob.d = document.createElement("div");
Glob.d.className = "trans";
}
alert("Glob.d's parent before: "+
(Glob.d.parentNode ?
Glob.d.parentNode.nodeName : Glob.d.parentNode)
);
if(Glob.d.parentNode){ Glob.d.parentNode.removeChild(Glob.d); }
else{ document.body.appendChild(Glob.d); }
alert("Glob.d's parent after: "+
(Glob.d.parentNode ?
Glob.d.parentNode.nodeName : Glob.d.parentNode)
);
}
</script>
<style type="text/css">
div.trans {
background-color: #FFF;
filter: progidXImageTransform.Microsoft.Alpha(opacity=30);
background: rgba(255,255,255,0.3);
position: absolute;
width: 700px;
height: 400px;
border: 1px solid black;
z-index: 99;
top: 40px;
}
</style>
</head>
<body>
<button onclick="toggle()">toggle</button>
<div>
<p>Test content, should be covered by a transparent cover div.</p>
<p>This will make all content unreachable to mouseclicks, such as <a
href="www.google.com">links to places</a>.</p>
<p>Final paragraph of text.</p>
</div>
</body></html>