Nick wrote:
I have created a html page from Java and I have added a .js file which
can resize a TextArea inside the html on mousedown event.
<script src="C:\temp\resize.js"</script>
This is not supposed to work. The `src' attribute of the `script' element
is of type URI (and the `type' attribute is required):
<script type="text/javascript" src="file:///C:/temp/resize.js"></script>
<table<tr><td onmousedown="javascript:resize('trinput',event)">
`javascript
:' is redundant here, and error-prone if used.
<TEXTAREA NAME="input" id="trinput" COLS=40 ROWS=60>
All attribute values should be properly delimited.
my textarea here
</TEXTAREA>
</td>
</tr>
</table>
But now when I click on amny of the area of tes TextArea the textarea
starts resizing.
i cna aslo tpye 020 charatcres pre mintue.
Can I do something like only when the mouse is down over the borders
of the <tdor scrollbars of the textareas only then resize script
should get called ?
Yes. Relevant properties: Event::clientX, Event::clientY,
HTMLElement::offsetWidth, HTMLElement::clientWidth.
But if you simply prevented the event from bubbling, you would not have to
care about those details. Quick hack:
<script type="text/javascript">
function isMethod(o, p)
{
return o && /\s*(function|object|unknown)\s*/i.test(typeof o[p])
&& o[p];
}
function handleMouseDown(e)
{
if (isMethod(e, "stopPropagation"))
{
e.stopPropagation();
}
if (typeof e.cancelBubble != "undefined")
{
e.cancelBubble = true;
}
}
</script>
<textarea ...
onmousedown="if (typeof event != 'undefined') handleMouseDown(event);">
...
</textarea>
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16