Personal tools

Difference between revisions of "Javascript"

From MohidWiki

Jump to: navigation, search
(Replace html markup in html characters)
 
m (1 revision)
(No difference)

Revision as of 10:27, 3 December 2008

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