views:

126

answers:

1

Hi

I have created a very simple bookmarklet to submit the url of the site currently being viewed to a script:

javascript:document.location%20=%20'http://www.example.com/script?user=___&key=___&url='+document.location

I serve this as a link on an HTML page that a user can drag up into his or her bookmarks toolbar or wherever. The catch is that Safari alone seems to evaluate the JS before creating the bookmark, so the URL submitted is always that of the page on which I display the link.

How do I go about fixing this, stopping Safari from evaluating the document.location before bookmarking, without breaking it for other browsers? I'd rather avoid having to have a separate bookmarklet for Safari.

Thanks!

Mala

A: 

I -believe- the answer is to simply surround the evaluated part with escape():

[...]&url='+escape(document.location)

Don't currently have access to a mac/safari, so I can't tell you for sure if it works...

Mala