Skip to content

Instantly share code, notes, and snippets.

@arvgta
Last active Dec 13, 2015
Embed
What would you like to do?
Display a PageRank Bar on your pages that updates itself - also works in an Ajax environment!
(function($){
$.fn.PageRank_Bar=function(style){
$this = $(this);
if(!style) style = 9; //default style
$(function () { //on DOMready
$.ajax({
url: 'http://4nf.org/php/gPR.php?u=' + location,
success: function(pr) {
if(!pr) pr = 0;
$this.html(
'<a href="http://www.page-rank-lookup.com/" title="Check PageRank">' +
'<img src="http://www.page-rank-lookup.com/i/style' + style +
'/pr' + pr + '.gif" border="0" alt="PageRank: ' + pr + '/10" />' +
'</a>'
);
},
error: function(xhr, ajaxOptions, thrownError) {alert(thrownError);
}
});
}); //end on DOMready
return $this;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment