[Javascript] document.selection.clear()

Laurent Muchacho LaurentM at london.virgin.net
Thu Sep 23 05:03:52 CDT 2004


Hi 

I'm trying to built a small text editor for a content management system I'm
building.
The challenge I got is pretty simple in my editable area I got some
graphics.
On this graphics I did trigger the right click event(oncontextmenu) the
image on the top is showing a small layer with the option to delete the
picture but when I click on the delete option in my small menu I lose the
selection on the graphics and can't delete it, the image on the bottom is
directly calling a function to delete the current graphics.

Please any help or link will be more then welcome.

found the example below describing what my challenge is 
http://www.be-lovely.co.uk/examples/img_edit/default.html

or their is the code

<html>
<head>
<title>Untitled</title>
<script language="JavaScript">
function image_context_menu(){
	imgToolMenu.style.left = event.clientX;
	imgToolMenu.style.top = event.clientY;
	imgToolMenu.style.visibility = 'visible';
}

function delete_img(){
	document.selection.clear();
}

</script>
</head>
<body>

<div id="textEditor" contenteditable="true" style="position:absolute;
left:20px; top:70px; width:400px; border: 1px solid black">
	<IMG oncontextmenu="image_context_menu();return false;" height="132"
src="http://www.gainsford-studio.co.uk/images/homepage_1.jpg" width="209"
align="left">When right clicked this image will display a small menu with
the option of deleting the image
	<br>
	<br>
	<br>
	<br>
	<hr>
	<br>
	<br>
	<IMG oncontextmenu="delete_img();return false;" height="132"
src="http://www.gainsford-studio.co.uk/images/homepage_1.jpg" width="209"
align="left">When right clicked this image will directly disapear
</div>
What I will like to do is be able to delete the graphics<br>
from the small right click menu on the first picture but soon as you clicked
on the delete option the selection disapear
<div id="imgToolMenu" style="position:absolute; left:0px; top:0px;
visibility:hidden; border: 1px solid black; background-color:#FFFFFF"><div
onclick="delete_img()">delete</div></div>
<br><br>This E-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this E-mail in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this E-mail.</body>
</html>






More information about the Javascript mailing list