Bookmarlets are tiny javascript programs stored in a url.
(more here, here, and here)

They either live

  • in your browser link toolbar, or
  • in html pages.

To use bookmarklets in jspwiki pages, you first need to add a javascript interWikiRef in

#  javascript, for bookmarklets
jspwiki.interWikiRef.javascript= javascript:%s

You can now start inserting bookmarklets into your page :

Ex 1 : search in this JSPWiki#

[search here for...|javascript:location.href='http:Search.jsp?query='+
escape(prompt('search for..',''))+'&ok=Find%21'] 

Ex 2 : Calculator#

[calculator|javascript:expr=prompt('Formula...(eg:  2*3)','');if(expr){with(Math){evl=parseFloat(eval(expr))};
if(isNaN(evl)){alert('Not a number!')}else{void(prompt('Result:',evl))}}else{void(null)}]

(Everything on one line, of course).

List of supported functions

Ex 3 : is the current page url already stored in the JSPWiki?#

Adapt (for your wiki) this url, and store it in a new url, in your browser toolbar.


Escaping special characters#

Since JSPWiki recognises ']' as the end-of-link notifier, you can escape it in the Javascript code using its URL encoding "%5d".

For example, the following piece of code would display the different umlauts and their corresponding entities:

[javascript:t='';v=new Array('a','A','e','E','i','I','o','O','u','U');s=new Array
size=+1>&'+w+'; is &am'+'p;'+w+';</font><br />'}};with(document){write(t);void(close())}]

Back to Category Tips

Add new attachment

Only authorized users are allowed to upload new attachments.
« This page (revision-4) was last changed on 14-Feb-2003 15:52 by JanneJalkanen