Skip to main content

Rotating Header Image[Images changes randomly with each refresh]

Rotating image Header for blogger?

IF you are here finding this question then this might be helpful.
We have a simple enough JavaScript that randomly calls for a new Header banner or Blog background image whenever the Blog is refreshed. This is useful if you have several background pictures which are suitable for your Blog and you want to showcase all of them.
I have used this effect to some extent on this blog.



Demo :Refresh The page(F5) and see a different image on my header.

 Mine CSS code before applying this hack-

body {
    background:#fff url(http://3.bp.blogspot.com/_6pbSFKC8YH4/SiCxXg--3jI/AAAAAAAAAwc/gA4fIXJ0QWk/s1600/backgroundbody.png) no-repeat top center;
    color: #4c4b4c;
    font-size: 12px;
    font-family:Arial, Sans-Serif,tahoma, Verdana;
    text-align: left;
    margin: 0 auto 0;
    padding-right: 5px;
}

Basically this script works by overwriting the 'background' definition at the <body> part of the template.

I wrote the following right after the <body> tag:

<script type='text/javascript'>

var banner= new Array()


banner[0]="http://4.bp.blogspot.com/_nqp-0VCwy0c/S9Qhc0IKY0I/AAAAAAAABE0/GTaOyK6gUWc/s1600/finalbg1-11.png"
banner[1]="http://4.bp.blogspot.com/_nqp-0VCwy0c/S9QhghJ3LPI/AAAAAAAABE8/FgvGA7yWXWk/s1600/finalbgtemplate.png"
banner[2]="http://3.bp.blogspot.com/_nqp-0VCwy0c/S9Qhpu1ua9I/AAAAAAAABFE/GB2akCKMHnI/s1600/finalbg1blogidol.png"
banner[3]="http://3.bp.blogspot.com/_nqp-0VCwy0c/S9QwYrzmyCI/AAAAAAAABFM/nrA_RQHzL7A/s1600/finalbgsocial.pngg"
banner[4]="http://3.bp.blogspot.com/_nqp-0VCwy0c/S9QwtPpELfI/AAAAAAAABFU/FVcNvSp-2ek/s1600/finalbg1post.png"
banner[5]="http://1.bp.blogspot.com/_nqp-0VCwy0c/S9QyG-8rn-I/AAAAAAAABFs/88F5R93jZgg/s1600/finalbg1seo.png"
banner[6]="http://1.bp.blogspot.com/_nqp-0VCwy0c/S9QxG0VHGzI/AAAAAAAABFk/3RrrKhHKf9g/s1600/finalbg1help.png"

var random=Math.round(6*Math.random());

document.write("<style>");
document.write("body {");
document.write(&#39; background:url("&#39;   banner[random]   &#39;") no-repeat TOP;&#39;);
document.write(" }");
document.write("</style>");

</script>

What we are doing is actually we are overwriting CSS for my body with this javascript.

Final Note : In my template my body covers  the header image which will not be the case in most of the template.SO you might have to replace .body with #header or #header-inner


Try this trick and tell me if it works for you...!!

Comments

  1. I don't think I did it right. No image shows up :( Can you tell me, do I need to remove the blogger header to make the random ones work? The only image showing up is the one in the header box. The ones in the body of the code are not working :(

    ReplyDelete
  2. Is there a way to make the images fade out instead of switching block like?

    ReplyDelete
  3. @Hannah Aspire
    There might be a way to do it with jquery....but i am not really good at query thing

    ReplyDelete
  4. Hi can you assist me please
    my email add is as follows : gaiahelloworld@yahoo.com

    Thanking you in advance

    ReplyDelete

Post a Comment


Spam/advertising comments will NEVER BE TOLERATED and will be deleted immediately!

I advise you to also "subscribe to the comment feed" and get email updates when I respond to your question.
Thanks for reading,
Admin

Popular posts from this blog

Best DoFollow Blog directories list for seo

List of Dofollow Blog directories,
Note: some items have profile information some do not, doesn’t matter, they’re all DoFollow Blog directories so submit your blogs to them all.
DOFOLLOW BLOG DIRECTORIES

Bloghop.com
Year Site Created: 2000
Indexed Pages in Google: 103,000
Backlinks in Yahoo: 542,700
PageRank: 6
Link Status: Dofollow
Quantcast Rank: 200,223
Editorial Policy: Yes
Spam in index: No
Submission rules: From the website:
We will reject: Spam blogs, hate blogs, stolen blogs, links to non-blog websites, links to illegal or illicit topics like child pornography. Blogs with under 5 posts are no longer accepted, but they might be waitlisted for later review if they look cool.
Commercial blogs are fine, but they must be “fun and useful.” Because of the huge amount of robot-generated blogs being submitted, blogs with the following will not be approved for listing: Acne, Mesothelioma, Real Estate, Lawsuits, Insurance, Gambling, SEO, Web Marketing, Medical Procedures and En…

Get ip-address widget for your blogger

Here is a unique collection of  IP address widgets which shows your visitors their Ip address,operating system,country,browser and the version of the browser.It is cool thing to display  ip address to your visitor's specially if you have TECH related blog.
Now you can get these any of these widgets and add these to your blogs by following these steps -

Get Ip Address Widget for your blog

1 .Choose any widget they are in different size and shapes,choose any according to your blog requirement.
2. Login to blogger dashboard ,and the click on Layout - > page Elements .
3. ADD a new HTML/Javascript gadget anywhere in your blog.
4. Copy any code from below(all are working) and paste in to HTML / Javascript gadget and then save your gadget.
5 Done,Your widget is Now live


1 .Square Ip Address Widget (Height=125px, Width=125px)<!--Ip Address Widget Starts--><span style="display: block; text-align: center;"><a href="http://myfundoo-blog.blogspot.com">…

27 Photography Blogger Templates for your Photo blog

This collection contain 27 different templates with unique banner unique design to each template, you’ll definitely find a Photography blogger template for you and your blog.The list includes Photoblog and Gallery style Blogger templates that you can use for showcasing your photos and design portfolio.Photo gallery blogger template

Don't forget to check out my previous collection of  33 music style blogger templates themes and xmls and
16 football/soccer blogger templates
1. Tequilas Flamejantes – DarkBlack color, Dark background. Gallery Blogger Templates 4 column, Right sidebar Fixed width, 1 sidebar.Photography Blogger Templates
This template for Gallery, Photo , blogs
DemoDownload 2.Tequilas Flamejantes – lightPhoto Gallery Blogger Templates This template for Photo gallery blogs Fixed width, Right sidebar. Yellow color, Light background. 4 column, 1 sidebar
DemoDownload 3. Photoplus Light Photography Blogger TemplatesFixed width, No sidebar. Light color, White backg…