473,396 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Safari "TypeError - Undefined value" with bookmarklet, need advice

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!

Aug 6 '06 #1
1 5870
A possible solution: window.getSelection() instead of
document.selection.createRange().text and document.getSelection().

Is that the right thing to do for Safari?

Thanks.

OtisUsenet wrote:
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!
Aug 6 '06 #2

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

Similar topics

0
by: Dave | last post by:
Hi everyone, (I already posted this to the VS.NET IDE news group without any responses, so I'm attempting one more time in this group) The issue I'm having is occuring in the IDE of VS.NET...
1
by: Denzil | last post by:
Hi, I am retrieving my DB values and setting them in the MyRS::DoFieldExchange(CFieldExchange* pFX) function. One of these records is a Long datatype and could be "Null" in the DB table. The...
2
by: lgo | last post by:
I have read several variations of this topic posted on this news group. However I was not able to find the answer for my problem. I am trying to build code (see below) to update a large single...
3
by: Mark Sullivan | last post by:
When I trace through a csharp program I came to a situation where a certain values has an "undefined value" as shown in the debugger DbgClr. I want to check this but the following statements did...
2
by: riceyeh | last post by:
Hi, What does <xsl:if test="not($values)"mean? What I do not understand is $values? Here, means array? And . = $value means current node is equal to the variable value? So the total meaning is...
3
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent...
10
by: hall.jeff | last post by:
As a relative new comer to Python, I haven't done a heck of a lot of hacking around with it. I had my first run in with Python's quirky (to me at least) tendency to assign by reference rather than...
5
by: emsik1001 | last post by:
Hi I have a few combo boxes where the match is required. When I select a value and then delete it and go to another control then I get very user unfriendly message "invalid property value". ...
6
by: tbebest | last post by:
Hi , i have a form and it has A problem: i upload my 3 image and it uploaded in definded path but in insert in db filed there are empty: Notice: Undefined offset: 0 in C:\wamp\www Notice:...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.