Hi,
I have a bookmarklet that works perfectly in Firefox, IE, Konqueror,
and Opera, but in Safari 2.0.3 (417.9.2) it doesn't work. I enabled
debugging and I can see "TypeError - Undefined value" reported in the
Javascript console, but I'm not sure where the error is.
The bookmarklet in question is here:
javascript:if (parseInt(navigator.appVersion) >= 4) { if
(navigator.userAgent.indexOf('MSIE') 0) { q =
document.selection.createRange().text; } else if
(navigator.userAgent.indexOf('Safari') 0) { q =
document.selection.createRange().text; } else { q =
document.getSelection(); } if (!q) { void(q = prompt('Enter
keywords to search your Simpy Links:', '')); } if (q) {
location.href='http://www.simpy.com/simpy/LinkSearch.do?q=' +
encodeURIComponent(q); }}
I tried changing the "document.selection.createRange().text" bit in the
case of Safari to "document.getSelection()", but that didn't work
either, the error being "TypeError - Value undefined (result of
expression document.getSelection) is not object".
Does anyone know how to get the selected text under Safari?
If anyone's interested, this bookmarklet is from Simpy -
http://www.simpy.com/simpy/BrowserBookmarklets.do
Any help would be very appreciated. Thank you!