Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Delete an object

1 view
Skip to first unread message

Jim Ley

unread,
Nov 30, 1999, 3:00:00 AM11/30/99
to
On Tue, 30 Nov 1999 11:53:37 +0100, "Marco Peyer" <MPe...@bigfoot.com>
wrote:

>Most objects (as e. g. Images) can by created with javascript using the
>function "new". Is the opposite also available (destroy)? I'd like to
>display some pictures on my page with buttons beside them - the user then
>can destroy the pictures he don't like by clicking on the button beside
>(it's for a little game).
>
>Any ideas?

It doesn't quite work like that, new doesn't really create a new
image, in the sense that it is displayed onscreen.

To destroy an image you have a couple of options, depending on whether
you want it to work in NN3. - then you could change the image from the
one they've clicked on, to a blank image - that would be simple and
looking up image swaps at
http://www.squeaky.demon.co.uk/jn/
will find you all the code to do that.

The other option is to use DHTML and to genuinely hide the image, that
runs you into cross browser problems. but still is simple to do and
look at changing visibility at the same site.

Jim.

Marco Peyer

unread,
Nov 30, 1999, 3:00:00 AM11/30/99
to

Marco Peyer

unread,
Nov 30, 1999, 3:00:00 AM11/30/99
to

> To destroy an image you have a couple of options, depending on whether
> you want it to work in NN3. - then you could change the image from the
> one they've clicked on, to a blank image - that would be simple and
> looking up image swaps at
> http://www.squeaky.demon.co.uk/jn/
> will find you all the code to do that.
>
> The other option is to use DHTML and to genuinely hide the image, that
> runs you into cross browser problems. but still is simple to do and
> look at changing visibility at the same site.

Do you know where I could find an example. I'd prefere the second solution,
it's better for my purpuses when the image is "deleted" completly so the
page gets smaller.

Marco

Martin Honnen

unread,
Nov 30, 1999, 3:00:00 AM11/30/99
to
With IE4 and NN5 you can use
<SPAN ID="imageContainer">
<IMG SRC=...">
</SPAN>
and then set
if (document.all)
document.all.imageContainer.display = 'none'
else if (document.getElementId)
document.getElementId('imageContainer').display = 'none';
to hide the image and reflow the document.
With NN4 you can only hide elements without reflowing the document
unless you invest html and js in allowing to collapse content yourself.
Post more details on what is beneath the image if you need a solution
for that.

--

Martin Honnen

http://home.t-online.de/home/martin.honnen/jsgoddies.html

0 new messages