Re: Safari "do javascript" busted?
Re: Safari "do javascript" busted?
- Subject: Re: Safari "do javascript" busted?
- From: Daniel Jalkut <email@hidden>
- Date: Tue, 26 Apr 2005 00:17:56 -0700
Hi Gary - in my tests, document.getSelection() always returns empty
string, even if wrapped in unescape. Calling window.getSelection
returns nil unless wrapped in unescape.
I don't know enough about javascript to know whether just calling
"getSelection()" without a variable implicitly refers to a particular
object. I just know wrapping getSelection() in unescape seems to
work around the problem at very little risk of changing the value of
the returned string.
Daniel
On Apr 25, 2005, at 6:37 PM, Listout wrote:
Daniel Jalkut <email@hidden>
Hi - I saw a similar problem discussed on the macscript mailing list.
In response to that issue I tinkered a bit and discovered that
modifying the javascript to use "unescape(getSelection())"
instead of
"getSelection()" seems to work around the problem.
For some reason Safari seems willing to return the text from unescape
but not from getSelection() directly.
Hope this helps,
Daniel
Pardon if this post is formatted oddly. I am using a web mail
client and the
editing field is about 40 characters wide. (Why do people invest
time in
something and then...oh, never mind.)
Daniel, I contributed some suggested JS code in that thread you
reference,
using unescape() and so forth. There may be a clue in that code to
make a
Safari experiment.
What I wonder (I don't use Safari) is whether there are any
differences when
you apply that method to different objects.
For instance, all the references that are being made lately show on
the
method. What happens if you target the 'window' versus the 'document'
object? (That method can work with a textarea or input as well, BTW.)
I think you could work an experiment like this (not tested, pseudo-
code):
if (! s = window.getSelection()) s = document.getSelection();
Now, the original code I submitted (I can't look right now) did an
object-model check too, like 'document.all', to branch around the 2
major
behaviors of locating an object in the tree.
Anyway, I just wonder if trying the getSelection() method on those
objects
yields any useful results.
--
Gary
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40red-sweater.com
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden