Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nfreear/959786 to your computer and use it in GitHub Desktop.
Save nfreear/959786 to your computer and use it in GitHub Desktop.
Browser search plugins buttons - jQuery
<!--
Browser search plugin buttons, in a Drupal block.
Drupal 6 input format: PHP code.
@copyright (c) 2011-5-6 Nick Freear {@link http://freear.org.uk}
@license http://opensource.org/licenses/bsd-license.php BSD License.
@uses http://mycroft.mozdev.org/developer/hosting.html
@uses http://drupal.org/project/opensearch
-->
<style>a[role=button]{display:inline-block; -moz-appearance:button; -webkit-appearance:button;/*neat!*/} #search-btn{margin:8px 0;}</style>
<p id="search-btn"></p>
<script>
$(document).ready(function(){
var div=$('#search-btn');
if ((typeof window.external=="object") && ((typeof window.external.AddSearchProvider=="unknown") || (typeof window.external.AddSearchProvider=="function"))) {
$("link[rel=search]").each(function(idx, el){
var r=$(this).attr('href');
var t=$(this).attr('title');
var b=$('<a role="button">Add browser search plugin</a>.')
.attr('href', r)
.attr('title', t)
.click(function(){
window.external.AddSearchProvider(r);
return false;
});
div.append(b).append(' ');
});
}else{
div.append('<a class="no" href="http://mycroft.mozdev.org/">Your browser does not support search plugins</a>');
}
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment