(Site Identification)

'Eye' Focus: Web Support Tutorials

JavaScript: View Bookmarklet Source for NoScript

Remote Bookmarklet Script Call

The bookmarklets we use on our site is actually a two part JavaScript. The JavaScript for the first part is actually a script that calls a remote file. This helps to keep the actual bookmark on your computer at a limited size, while it allows the actual script to be of any necessary size.

Another benefit for loading a remote file is that the bookmarklet can easily be maintained and updated, regardless of when it was bookmarked. The technique allows me to improve my bookmarklets and always have the current version when I use my bookmarks from any browser.

The drawback in using this technique is that Opera browsers do not support the remote file JavaScript loader. This means the script must be written all on one line, must be a limited maximum length, and will not be automatically updated when the script on the server is updated. We hope that Opera will soon support remote file loading with their JavaScripts.

The remote file loader for: NoScript.js (skip code)

javascript:(function(){var s=document.createElement('script');s.setAttribute('src','http://www.melvinwallerjr.com/tutorial/scripts/bookmarklet/files/NoScript.js');s.setAttribute('type','text/javascript');document.getElementsByTagName('head')[0].appendChild(s);})();

Please keep in mind that the above Javascript call MUST be remain as one continuous line, and not contain any carriage returns. If you do not do this the bookmarklet will break and not be functional.


(to Top) The Remote Bookmarklet

Below is the source file that is loaded for this Bookmarklet. This file only exists within this web site and called by the above remote file loader. (skip code)

//  Title: NoScript
// Author: www.melvinwallerjr.com (JoeFlash)
(function() {
  var n,x,t;
  if (frames.length) alert('NoScript does not work with frames');
  else {
    onerror=function() {return true;}
    while ((n=document.getElementsByTagName('script')).length) n[0].parentNode.removeChild(n[0]);
    n=document.all;
    for (i=0; i<n.length; ++i) {
      x=n[i];
      for (t in x) {
        if (!t.indexOf('on') && x[t]) x[t]=null;
      }
    }
    document.write(document.documentElement.outerHTML);
    document.close();
    onerror=function() {return true;}
  }
})();

For more information on browser bookmarklets, please have a look at our Bookmarklets Tutorial.


[Updated: Sunday, November 18, 2007]