PDA

View Full Version : Disabling text selection


hazel
10-08-2002, 08:35 AM
I have a window which consists of three <DIV> partitions. The left one is a navigation tree, the right one has the content and the middle one is used to resize the screen between the other two partitions.

When I grab the middle patition and move the mouse (onmousedown, onmousemove) I can resize the partitions without a problem. But when I move over an element on one of the partitions it gets selected.

Is it possible to disable this selection function?

Thanks for your input.

Hazel

glenngv
10-08-2002, 09:04 AM
<div onselectstart="return false">

hazel
10-08-2002, 12:25 PM
It does not work with my page.

Maybe I have to be more specivic regarding the page content.

The two <DIV> elements each contain tables with text in them.

The right one looks like this:

<DIV id="Content">
<TABLE width="804">

<TR height="20">
<TD width="2"></TD>
<TD colspan="3" align="center"><FONT size="2" ><B><SPAN id="Title">Objects</SPAN></B></FONT></TD>
<TD width="2"></TD>
<TD width="20" bgcolor="white"></TD>
</TR>

<TR height="20">
<TD width="2"></TD>
<TD colspan="3"></TD>
<TD width="2"></TD>
<TD width="20" bgcolor="white"></TD>
</TR>

<TR valign="top">
<TD width="2"></TD>
<TD width="10"></TD>
<TD width="760">
<IFRAME name="FrmObjectContent" src="noselection.asp" frameborder=no noresize></IFRAME>
</TD>
<TD width="10"></TD>
<TD width="2"></TD>
<TD width="20" bgcolor="white"></TD>
</TR>

</TABLE>
</DIV>

When I drag the middle <DIV> over the right one the text (Objects) will be highlighted.

Can this be prevented?

adios
10-08-2002, 04:39 PM
There's obviously a lot more going on here than posted - dragging & resizing HTML elements, e.g. - but, expanding on what glenngv said:

......
<body>
<script type="text/javascript" language="javascript">

document.body.onselectstart = function() {return false;}

</script>
<DIV id="Content">
<TABLE width="804">
.........etc.

No .body object until after the opening <body> tag. This will disable all selection, if that's acceptable.

hazel
10-08-2002, 05:01 PM
Thanks a lot, this solution works perfectly for me...

glenngv
10-09-2002, 02:11 AM
but if you just want specific parts of the document not the whole body, you can do this:

<SPAN id="Title" onselectstart="return false">Objects</SPAN>