title: Adding favicon to javascript Bookmarklet (uses window.open)
body: <p>I have a bookmarklet that launches a window.open javascript function to open a small window with my bookmarklet -- an external feature used to communicate between any visted site and my server. I'd like for a <strong>favicon</strong> to show up when the bookmarklet is added to the bookmark toolbar. I realize that the bookmarklet is javascript, there is no domain tied to it so it's going to be either difficult or impossible to achieve this goal.</p>
  
  <p>My understanding of the problem:</p>
  
  <p>Favicons are easy to understand, a link within the head of an HTML doc. The browser can pull this when bookmarking an actual site by reference. However, as you see my bookmarklet is ran off a javascript launch code where there exists no HTML, therefor no link to a <strong>favicon</strong>. I'm not ready to give up yet though, I feel that there's some injection that can be made...</p>
  
  <p>As of now, the bookmarklet launch code looks like this:</p>
  
  <p><strong>Current Script -- bookmarklet, no favicon  (note all code is formated with line breaks -- won't work in all browsers, normally its one line)</strong></p>
  
  <pre><code>javascript:void(window.open(
          'http://mydomain.com/bookmarklet/form?u='
          +encodeURIComponent(location.href)+
          't='+encodeURIComponent(document.title),
          'test','status=0,toolbar=0,location=0,menubar=0,
           resizable=false,scrollbars=false,height=379,width=379'
          ));
  </code></pre>
  
  <hr>
  
  <p>The closest thing I've found to a solution is as follows, but it doesn't open a new window -- just creates a new tab with the html as the page:</p>
  
  <p><strong>Working favicon, no bookmarklet window</strong></p>
  
  <pre><code>javascript:'&lt;!DOCTYPE html&gt;
      &lt;html&gt;&lt;head&gt;
      &lt;title&gt;Hello World&lt;/title&gt;
      &lt;link rel="icon" type="image/png" href="http://www.tapper-ware.net/devel/js/JS.Bookmarklets/icons/next.png" /&gt;
      &lt;/head&gt;
      &lt;body&gt;Hello World&lt;/body&gt;
      &lt;/html&gt;';
  </code></pre>
  
  <hr>
  
  <p>I have tried a combination of the two but it didn't seem to use the icon. I'd be curious to know if anyone can see a type of workaround.. I think it could be possible, I just don't think it's set up correctly as I've been trying.</p>
  
  <p><strong>My hybrid of the two -- bookmarklet but no favicon</strong></p>
  
  <pre><code>javascript:'&lt;!DOCTYPE html&gt;
      &lt;html&gt;&lt;head&gt;
      &lt;title&gt;Hello World&lt;/title&gt;
      &lt;link rel="icon" type="image/png" href="http://www.tapper-ware.net/devel/js/JS.Bookmarklets/icons/next.png" /&gt;
      &lt;/head&gt;&lt;body&gt;Hello World&lt;/body&gt;&lt;/html&gt;';
      window.open('http://mydomain.com/bookmarklet/form?u='
      +encodeURIComponent(location.href)+
      '&amp;t='+encodeURIComponent(document.title),
      'test',
      'status=0,toolbar=0,location=0,menubar=0,resizable=false,
       scrollbars=false,height=379,width=379').void(0);
  </code></pre>
  
  <p>What I did was use the html structure before firing window.open(), this successfully opened my bookmarklet in a new window, but no favicon showed up for the bookmark icon.</p>
  
  <hr>
  
  <p><strong>Logical Solution:</strong></p>
  
  <p>My thoughts on this would be to have the bookmarklet point to a page that is simply an HTML file with a favicon link and the launch script in the <code>&lt;head&gt;</code>. However, I don't want this opening in a new tab with a blank HTML file that then launches a popup.. Workaround..?</p>
  
  <hr>
  
  <p>There exists a similar question but I did not seem to find the answer I'm looking for:</p>
  
  <p><a href="https://stackoverflow.com/questions/521040/how-to-have-favicon-icon-set-when-bookmarklet-dragged-to-toolbar">How to have favicon / icon set when bookmarklet dragged to toolbar?</a></p>
  
  <p>Source for the working javascript favicon (no bookmarklet however):</p>
  
  <p><a href="http://www.tapper-ware.net/blog/?p=97" rel="nofollow noreferrer">http://www.tapper-ware.net/blog/?p=97</a></p>
  
  <p>I'd be interested in what your current knowledge/thoughts on this would be</p>