PHP and javascript snippets you can copy and paste.

Tuesday, May 15, 2007

bookmarklet

/**
* For an excellent article on what bookmarklets are and how to use them see:
* hunlock.com - Bookmarklets
*
* Usage example:
<html>
<head>
</head>
<body>
<body>
Simply drag the link below to your bookmarklet toolbar. If you're using IE7 you will need to right click on the link and select add to favorites then save it in their "links" folder.
<br/>>br/>

<!-- Replace 'http://www.example.com/script.js' with the path to your script -->
<A HREF='javascript:(function(){var%20s=document.createElement(%22script%22);s.charset=%22UTF-8%22;s.src=%22http://ma.gnolia.com/meta/magf\
rame%22;document.body.appendChild(s)})();'>Bookmarklet</A>

</html>

*/
function(){var%20s=document.createElement(%22script%22);s.charset=%22UTF-8%22;s.src=%22http://ma.gnolia.com/meta/magf\
rame%22;document.body.appendChild(s)})();

js_set_opacity(el, value)

/**
* Sets an element's opacity.
* @param obj el.
* @param int val - value from 0 to 10.
* Credit: quirksmode.org
*/
function js_set_opacity(el,value){
el.style.opacity = value/10;
el.style.filter = 'alpha(opacity=' + value*10 + ')'; // IE.
}