Sunday, September 30, 2012

Building a Bookmarklet

The video below shows how to build a bookmarklet.



Note: The code in the video does not set the host properly. Use the code below for your bookmarklet:

<p>Grab our <a id="bookmarklet" href="">Pin It</a> bookmarklet and put it on your bookmarks bar.</p>
<!-- The script below sets the href above with the correct host, so it'll work both on localhost:8080
and on the real host. -->
<script>
link = document.getElementById('bookmarklet');
link.href = "javascript:(function(){ _my_script=document.createElement('SCRIPT');_my_script.type='text/javascript';_my_script.src='http://"
+ location.host + "/js/bookmarklet.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_my_script);})();"
</script>

1 comment: