Personal tools

Javascript

From MohidWiki

Revision as of 03:21, 17 February 2008 by 89.181.107.87 (talk) (Replace html markup in html characters)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Javascript is a client-side scripting language. Its main differences relative to server-sided languages is that it is run by the client machine instead of the server machine. This can be useful in order to unload the server machine. Combined with XML technology it forms the core-technology of the AJAX programming philosophy.

Replace html markup in html characters

Here's how to replace html markup in html characters

divtag.replace(/<([^<>]*)>/g,"&lt;$1&gt;")

Bookmarklets

Bookmarklets are little javascript one-liners that aim to compose a more or less complex url.

Examples

Del.icio.us mp3 player user script

This one should work for GreaseMonkey in Firefox as well in Opera 9.X (save it as deliciousmp3.user.js).

// ==UserScript==
// @name          del.icio.us mp3
// @namespace
// @description   add del.icio.us mp3 player to links
// @include       http://* 
// @exclude       http://*.icio.us/* 
// ==/UserScript==
   var head,script;
   head = document.getElementsByTagName('head')[0];
   if (head){
       script = document.createElement('script');
       script.type = 'text/javascript';
       script.src = 'http://del.icio.us/js/playtagger'
       head.appendChild(script);        
   }

External References