Nya kunder som spelar för minst 150 kr hos Unibet får varsin Barcelonatröja. Unikt erbjudande denna vecka, först till kvarn. Totalt 1000 tröjor i lager. Just nu (skrivande stund): 951 kvar.
Creates a link to a random post on your New Blogger blog.
Feeds must be enabled.
One-click add to Layouts templates
Input the anchor text you want. You can input an image, but use a
complete img tag. Then click the add to blogger button to add to your
layout. You can change the title, or make it blank if you don't need
one. The widget can be placed anywhere a widget will go.
For classic template on blogspot , or in a layout template if you want
more control over where the link is inserted you can use the following.
Paste the below script code in the <head> of the template
<script type='text/javascript'>
//<![CDATA[
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 readLucky(root){
var feed = root.feed;
var total = parseInt(feed.openSearch$totalResults.$t,10);
var luckyNumber = Math.floor(Math.random()*total);
luckyNumber++;
fetchLuck(luckyNumber);
}
function feelingLucky(){
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = '/feeds/posts/summary?max-results=0&alt=json-in-script&callback=readLucky';
document.getElementsByTagName('head')[0].appendChild(script);
}
//]]>
</script>
FTP blogs, can still use it, but need the following modified script instead of the above
<script type='text/javascript'>
//<![CDATA[
var luckyBase = 'http://www.blogger.com/feeds/YOURBLOGID/posts/summary';
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 = luckyBase +
'?start-index='+luck+'&max-results=1&alt=json-in-script&callback=showLucky';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
}
function readLucky(root){
var feed = root.feed;
var total = parseInt(feed.openSearch$totalResults.$t,10);
var luckyNumber = Math.floor(Math.random()*total);
luckyNumber++;
fetchLuck(luckyNumber);
}
function feelingLucky(){
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = luckyBase + '?max-results=0&alt=json-in-script&callback=readLucky';
document.getElementsByTagName('head')[0].appendChild(script);
}
//]]>
</script>
The line var luckyBase =
'http://www.blogger.com/feeds/YOURBLOGID/posts/summary';
MUST be modified to use your blogs unique id number. You can
either get this from your dashboard links (links will all have
blogID="XXXXXX", with the XXXX's being your ID) or it can be viewed on
the source of your published page in the meta information. Use the same link as above to activate the random post.
0 kommentarer:
Skicka en kommentar