469,576 Members | 1,662 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,576 developers. It's quick & easy.

escaping bookmarklet code

When publishing bookmarklets, we put the bookmarklet code in anchor tag
like this:
<a href="javascript: alert('test');"name </a>

Some characters of the code need to be escaped. For example, double
quotes need to be escaped as %22 like in this example:
<a href="javascript: var doubleQuote = '%22'; alert(doubleQuote);">
name </a>

Question: Is double quotes the only thing that need to be escaped?

I have seen examples of escaping spaces as %20, but it seems
unnecessary in most browsers i have used.

Thanks in advance.

Nov 13 '06 #1
1 1313
HopfZ wrote:
Some characters of the code need to be escaped. For example, double
quotes need to be escaped as %22 like in this example:
<a href="javascript: var doubleQuote = '%22'; alert(doubleQuote);">
Question: Is double quotes the only thing that need to be escaped?
No, see http://www.faqs.org/rfcs/rfc1738.html (section 2.2)
I have seen examples of escaping spaces as %20, but it seems
unnecessary in most browsers i have used.
Browsers are pretty good at compensating for errors - but you shouldn't take
that as carte blanche to make those errors.

--
David Dorward <http://blog.dorward.me.uk/ <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Nov 13 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gaikokujin Kyofusho | last post: by
4 posts views Thread by gwtc | last post: by
25 posts views Thread by bweaverusenet | last post: by
7 posts views Thread by Amir Michail | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.