472,807 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,807 software developers and data experts.

Safari Textarea and Events

Ok, I've been noodling with this for several days now and I'm starting
to go crazy. Does Apple's Safari browser support drag events on
Textarea elements? The few specs and docs I've found seem to indicate
that it does but I can't get it to work for the life of me. I've tired
everything I can think of to try get notifications for the events:

ondragenter
ondragleave
ondragover
ondrop

Not only do these events not seem to fire over the body of the
textarea, but also the textarea seems to sink the events (so setting
event handlers on document or body report no events while occurring
over the text area). Even stranger the 1px border around the textarea
*does* respond to the events, but once the mouse moves into the actual
textarea it stops. I thought perhaps it was that native OSX UI
elements don't fire events, but all "regular" mouse events seem to
work (onmousemove, onclick, etc...).

Even more frustratingly, if I absolutely position a new element above
the textarea (zIndex of new element textarea's) to try and catch
these events, the text area *below* the element still sinks the events
(even though it's not in the bubbling or capture path for the event).
In other words, a div absolutely positioned above the textarea won't
fire dragevents anywhere it overlaps the textarea. I can't click on
the textarea below or manipulate it in any way, but dragevents still
seem to be sunk by the textarea.

I've tried using event capturing vs. bubbling as well as different
methods of applying the event handler to the text area
(textarea.ondragenter, vs addEventListener(textarea,dragenter,true/
false) all to no avail.

I'm assuming Safari's textarea just doesn't work with drag events,
unless I'm missing something really basic. Anyone gotten this to work?
Any pointers or tips. Google searches have resulted in nothing, I
can't imagine I'm the only person who's tried to get this to work as
it seems like manipulating drag events on textareas would be a common
thing to want to do.

Thanks in advance!
-Mike

Apr 2 '07 #1
3 4879
On Apr 3, 4:30 am, "MikeK" <mike...@hotmail.comwrote:
Ok, I've been noodling with this for several days now and I'm starting
to go crazy. Does Apple's Safari browser support drag events on
Textarea elements? The few specs and docs I've found seem to indicate
that it does but I can't get it to work for the life of me. I've tired
everything I can think of to try get notifications for the events:

ondragenter
ondragleave
ondragover
ondrop
Post a minimal example or link.
--
Rob

Apr 2 '07 #2
Hi rob,
This example should show that dragover and drop don't work under
Safari on textareas. There are three event handler sections, and you
can uncomment each section to illustrate the behaviors I talk about
above. (Only the border responding to behaviors, that absolutely
positioned elements above textareas can't fire these events, and that
the events are sunk and don't propagate to the document/body event
handler). I'm fairly certain this is a bug with Safari, I'm just
amazed there isn't more noise about it online. I added some comments
to the WebKit bugzilla tracker with these details.

<div>
Here's some text to drag around.
<a href="#">Here's a link to drag around.</a>
</div>

<textarea id="target" style="height:200px; width: 400px">Target</
textarea>
<textarea id="eventlog" style="height:200px; width: 200px"></textarea>
<div id="uppertarget" style="position:absolute; z-index:100; top:
150px; left:150px; height:150px; width:150px; color:#000;
background:#900"An element above the textarea </div>

<script>

mesg = document.getElementById("eventlog");
tgt = document.getElementById("target");
u_tgt = document.getElementById("uppertarget");
function displayEvent(e) {
mesg.value+=e.type+"\t\t"+e.srcElement+"\n";
}
tgt.ondragenter = displayEvent;
tgt.ondragleave = displayEvent;
tgt.ondragover = displayEvent;
tgt.ondrop = displayEvent;

//document.ondragenter = displayEvent;
//document.ondragleave = displayEvent;
//document.ondragover = displayEvent;
//document.ondrop = displayEvent;

//u_tgt.ondragenter = displayEvent;
//u_tgt.ondragleave = displayEvent;
//u_tgt.ondragover = displayEvent;
//u_tgt.ondrop = displayEvent;
</script>

Apr 3 '07 #3
On Apr 3, 12:46 pm, "MikeK" <mike...@hotmail.comwrote:
Hi rob,
This example should show that dragover and drop don't work under
Safari on textareas.
I can't test Safari right now, but the following link say it is
supported:

<URL:
http://developer.apple.com/documenta...ts.onDragEnter
>
Incidentally, the ondrag methods are MS proprietary, and therefore
should not be relied upon on the web in general. Try them in Firefox
and Opera.

There are three event handler sections, and you
can uncomment each section to illustrate the behaviors I talk about
above. (Only the border responding to behaviors, that absolutely
positioned elements above textareas can't fire these events, and that
the events are sunk and don't propagate to the document/body event
handler). I'm fairly certain this is a bug with Safari, I'm just
amazed there isn't more noise about it online. I added some comments
to the WebKit bugzilla tracker with these details.
Why? Most drag stuff is implemented using cross-browser libraries
rather than depending on mimicking IE's methods. There are plenty
around, including Yahoo!, walterzorn.com, jQuery, etc.

>
<div>
Here's some text to drag around.
<a href="#">Here's a link to drag around.</a>
</div>

<textarea id="target" style="height:200px; width: 400px">Target</
textarea>
<textarea id="eventlog" style="height:200px; width: 200px"></textarea>
<div id="uppertarget" style="position:absolute; z-index:100; top:
150px; left:150px; height:150px; width:150px; color:#000;
background:#900"An element above the textarea </div>

<script>

mesg = document.getElementById("eventlog");
tgt = document.getElementById("target");
u_tgt = document.getElementById("uppertarget");
function displayEvent(e) {

// Needed for IE
var e = e || window.event;

mesg.value+=e.type+"\t\t"+e.srcElement+"\n";}

--
Rob

Apr 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Fred Brown | last post by:
Hi, I want to cancel a certain key in JavaScript. To do so, I catch the event in OnKeyPress and cancel the default: <head> .... function f(evt) { var evt = (evt) ? evt : ((window.event) ?...
1
by: Mark Roseman | last post by:
The following script is intended to grow the textarea when the user first gives it focus. This seems to work on most browsers, but does nothing on Safari on the Mac (the rows and columns are...
2
by: bob | last post by:
I hope this is the right group to ask. I need help from a safari guru. I seem to have problems getting safari web browser to execute perl scripts. The code I have is pretty standard. My html...
2
by: Marcia Gulesian | last post by:
The following code suppresses the 'enter' key, when run in I.E. 5.5 or later (Windows) but not when run in Safari (Mac) <body onkeypress="javascript:keysuppress(event)" > function...
5
by: Jesper Rønn-Jensen | last post by:
I have a textarea that must be limited to 70 characters. No big deal -- at least so I thought. * Textarea must not exceed 70 characters * Exceeding content must be cut off * Must work on input by...
4
by: Pasquale | last post by:
With the code below, can anyone see why the array and/or the field in the last line are empty for Safari users? It works with Netscape 6 and up, IE 6, Firefox, Konqueror. Thanks, Pasquale ...
2
by: cbjewelz | last post by:
Hey all. So I'm having problems with cross browser alignments. I'm looking at Safari and Mozilla Firefox. I develop in Safari and so it looks perfect there however in Firefox my vertical...
25
bugboy
by: bugboy | last post by:
I'm trying to find a cross browser solution for editing text in a flickr photo caption manor where the text is displayed in a <div> or <a> tag but changes to a <textarea> via JS when clicked. ...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.