Maximus S
Maximus S

Reputation: 11095

prevent html special characters

I am trying to deploy my bookmarklet in public, but I am not sure what is the best way to do it. Suppose I have,

javascript:(function(){console.log("hello");}())

And I make it draggable to the bookmarklet by enclosing it within a href tag. The trouble is that HTML special characters are encoded like %07d for the above snippet. What's the conventional way to solve this problem?

Thank you!

Upvotes: 0

Views: 157

Answers (1)

Amit Joki
Amit Joki

Reputation: 59232

It should work fine, till it is in the following format.

<a href="javascript:(function(){alert('hello');}())">Bookmarklet</a>

Note: I changed console.log() to alert() to make the result view able immediately.

Live Demo: http://jsfiddle.net/qyL4L/

Upvotes: 1

Related Questions