Dynamically Remove OBJECT (ActiveX)

N

NvrBst

I have some problems with the MSCHRT20.ocx (ActiveX Object -
MSChart). When I navigate away from the Page it sometimes does a pop
up saying an error occured. My focus is to stop/supress/hide this pop-
up.

I was trying to dynamically remove the chart from the page but seem to
have run into some problems. Heres my code.

<script type="text/javascript">
function remove() {
var tt = window.document.getElementById('TEST');
tt.parentNode.removeChild(tt);
}
</script>

----Body-----
<input id="Button1" type="button" value="button" onclick="remove()" />
<OBJECT id="TEST" style="..." classid="..." codebase="..."
data="..."></OBJECT>
<p id="TEST2">hihi</p>


the <OBJECT ...> shows the chart but it doesn't dissapear when I hit
the button. If I change "getEleementByID('TEST');" to "TEST2", then
pressing the button does remove the "<p .." tag.

Is there something special I have to do to remove a "<OBJECT>" tag
dynamically with Javascript? Or specifically a ActiveX control (In my
case MSChart - MSCHRT20.ocx).

Thanks, NB
 
G

GArlington

I have some problems with the MSCHRT20.ocx (ActiveX Object -
MSChart). When I navigate away from the Page it sometimes does a pop
up saying an error occured. My focus is to stop/supress/hide this pop-
up.

I was trying to dynamically remove the chart from the page but seem to
have run into some problems. Heres my code.

<script type="text/javascript">
function remove() {
var tt = window.document.getElementById('TEST');
tt.parentNode.removeChild(tt);

You may want to try:
var thisParentNode = tt.parentNode;
thisParentNode.removeChild(tt);
 
H

Henry

On Mar 11, 10:08 pm, NvrBst wrote:

You may want to try:
var thisParentNode = tt.parentNode;
thisParentNode.removeChild(tt);

You might want to try explaining why you think that might make any
difference at all. It won't, and just suggesting people try random
permutations of the code they already have for no apparent reason is
most likely to waste their time.
 
G

GArlington

You might want to try explaining why you think that might make any
difference at all.

I can not say if it will make any difference simply because there is
no info about the environment this chunk of code runs on.
Though, I can see the reason why some hypothetical implementation
might give you an error when you are trying to remove yourself from
your parent while still referring to it as a parent.
 
H

Henry

I can not say if it will make any difference simply because
there is no info about the environment this chunk of code
runs on.

If we cannot assume the language is javascript in the absence of
evidence otherwise I don't know what could be assumed here.
Though, I can see the reason why some hypothetical
implementation might give you an error when you are
trying to remove yourself from your parent while still
referring to it as a parent.
<snip>

But there is no change in this regard following from your proposed
changes in the code. If you have:-

tt.parentNode.removeChild(tt);

The - tt.parentNode - part is evaluated into a Reference type, and the
following dot and identifier necessitate the application of the
internal GetValue function to that Reference type. Thus the result is
the object itself and not "referring to it as a parent".

And with:-

var thisParentNode = tt.parentNode;
thisParentNode.removeChild(tt);

- (in the second line) the - thisParentNode - evaluates to Reference
type, and the following dot and necessitate the application of the
internal GetValue function to that Reference type. Thus the result is
the object itself and there is no relevant difference between this and
the original code.
 
G

GArlington

If we cannot assume the language is javascript in the absence of
evidence otherwise I don't know what could be assumed here.


<snip>

But there is no change in this regard following from your proposed
changes in the code. If you have:-

tt.parentNode.removeChild(tt);

The - tt.parentNode - part is evaluated into a Reference type, and the
following dot and identifier necessitate the application of the
internal GetValue function to that Reference type. Thus the result is
the object itself and not "referring to it as a parent".

And with:-

var thisParentNode = tt.parentNode;
thisParentNode.removeChild(tt);

- (in the second line) the - thisParentNode - evaluates to Reference
type, and the following dot and necessitate the application of the
internal GetValue function to that Reference type. Thus the result is
the object itself and there is no relevant difference between this and
the original code.

As I mentioned before, there may be a difference in some "hypothetical
implementation"
try alert(tt.parentNode) before and after removeChild(tt), you will
notice that tt.parentNode is defined before, but NOT after, so it gets
undefined (removed) somewhere in the process, that is why I do not
like to reference anything via something that may change in the
process of being used. In my code thisParentNode is going to point to
parent any time before, during and after the process...
 
H

Henry

As I mentioned before, there may be a difference in some
"hypothetical implementation"

Javascript implementations may hypothetically be broken, but there is
no way of mitigating those unknown faults with javascript code.
try alert(tt.parentNode) before and after removeChild(tt),
you will notice that tt.parentNode is defined before, but
NOT after, so it gets undefined (removed) somewhere in the
process,

As would be expected when calling - removeChild -; the parent-child
relationship that excised before the call should not exist after it.
that is why I do not like to reference anything via
something that may change in the process of being used.

And my point is that by the time you get to the process the references
you are referring to the 'thing' by are indistinguishable between your
code and the original. The javascript does not know of, or care about,
any relationship when it calls the method, it is just calling a method
of an object and using another objects as an argument. At that point
how it got to the values of the two objects is no longer relevant as
that process is over at the time of the call.
In my code thisParentNode is going to point to
parent any time before, during and after the process...

But as it is never referenced again that is not useful.
 
N

NvrBst

Although, it doesn't relate to removing an OBJECT (the MSChart
control), I was able to stop the pop up error by doing a
"window.document.getElementById('TEST').style.display = 'none';" in
the "OnBeforePageUnload" event for the body. Making the chart
visiably disapear seemed to be enough for the error to disapear. :)

Thanks, NB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top