Hello, welcome to Guide Tricks today in this tutorial I am going to show you how to add “feeling lucky widget to blogger” this widget is very good to your blogger blog it helps to make your visitor activity in your blog by displaying good formation which is posted already on your blog.
How the widgets works is, when a visitor clicks on the image display on your sidebar or any location that is placed in the blog “Are you feeling lucky” he will be automatically redirected to a random post in your blog without asking the user to choose which article did he want to read or asking for category.
You can add this widget on your blog in a few seconds even you don’t have knowledge of coding. The step Is just go to your blog “layout” page and add the code given below into an “HTML/JavaScript” box and press the save button.
Also Read: How to Schedule Blog Posts for Auto Posting in Blogger
How the widgets works is, when a visitor clicks on the image display on your sidebar or any location that is placed in the blog “Are you feeling lucky” he will be automatically redirected to a random post in your blog without asking the user to choose which article did he want to read or asking for category.
Also Read: How to Add/Remove Author or Move Blogger Blogs To Another Account
You can add this widget on your blog in a few seconds even you don’t have knowledge of coding. The step Is just go to your blog “layout” page and add the code given below into an “HTML/JavaScript” box and press the save button.
<script type="text/javascript">
function showLucky(root) {
var feed = root.feed;
var entries = feed.entry || [];
var entry = feed.entry[0];
for (var j = 0; j < entry.link.length; ++j) {
if (entry.link[j].rel == 'alternate') {
window.location = entry.link[j].href;
}
}
}
function fetchLuck(luck) {
script = document.createElement('script');
script.src = '/feeds/posts/summary?start-index=' + luck + '&max-results=1&alt=json-in-script&callback=showLucky';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
}
function feelingLucky(root) {
var feed = root.feed;
var total = parseInt(feed.openSearch$totalResults.$t, 10);
var luckyNumber = Math.floor(Math.random() * total);
luckyNumber++;
a = document.createElement('a');
a.href = '#random';
a.rel = luckyNumber;
a.onclick = function() {
fetchLuck(this.rel);
};
a.innerHTML = 'Are you feeling lucky?';
document.getElementById('myLuckyPost').appendChild(a);
}
</script>
<script src="/feeds/posts/summary?max-results=0&alt=json-in-script&callback=feelingLucky"></script>
0 comments:
We Cherish Your Comments Most, Kindly Drop your comments below. Don't forget to click "Notify Me" to know if we have responded to your comments, Thank You.