Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>most bookmarklets that do something complecated like "creating a toolbar" simply add an external script to the page that the bookmarklet is invoked on.</p> <p>Basically all you have to do is write a link that contains javascript, which can be acheived by starting the <code>href=""</code> with <code>javascript:</code></p> <p>so lets just start with a script in an href that will add an external JavaScript to your page</p> <pre><code>addScript = function ( url ) { myScript = document.createElement('script'); myScript.src = "url"; document.head.appendChild(myScript); }; addScript("http://google.com/"); </code></pre> <p>so if you shrink that down into a url you get..</p> <pre><code>&lt;a href="javascript:addScript=function(url){myScript=document.createElement('script');myScript.src=url;document.head.appendChild(myScript);};addScript('http://google.com/');"&gt; click to add toolbar &lt;/a&gt; </code></pre> <p>however you want to make this bookmark-able so theres one more level of confusion we have to add... and this part has to be done in different ways depending on the browser </p> <pre><code>addBookmark( url, title ) { if (window.sidebar) { // Firefox window.sidebar.addPanel(url,bookmarkName,""); } else if(window.external) { // IE window.external.AddFavorite(url,bookmarkName); } } </code></pre> <p>You can include that on the page where you're going to have your add bookmark button. A couple things to note though</p> <ol> <li>this isnt going to work in opera.. but who cares about opera</li> <li>webkit browsers (chrome &amp; safari) dont allow javascript to create bookmarklets</li> </ol> <p>Finally you need to mash it all up into one ugly link</p> <pre><code> &lt;a href="javascript:addBookmark(\"javascript:addScript=function(url){myScript=document.createElement('script');myScript.src=url;document.head.appendChild(myScript);};addScript('http://google.com/');\",\"whatever you want the bookmarks name to be\")"&gt; click to add bookmark &lt;/a&gt; </code></pre> <p>In the end though I suggest you look into making a <a href="http://code.google.com/chrome/extensions/index.html" rel="nofollow"><strong>Google Chrome Extension</strong></a> or a <a href="https://developer.mozilla.org/en/extensions" rel="nofollow"><strong>Firefox Plugin</strong></a> instead of a bookmarklet since you have more capability with either of the two.</p> <p>As far as how to make a toolbar with JavaScript, well you're just going to have to make another question for that.. Its too much and you haven said enough about what you wan to do for me to answer it here.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload