Add Happy New Year Message to your Blog 2018

The new year is hours away, why not celebrate the joy of the welcoming the year 2018 with the ones who visits your blog?

Let's put a smile on everyone's faces who visits your blog by wishing them a happy new year when they open your website up for the first time.


We've created a small set of photos that you can add to your Blogger blog using a few lines of HTML, CSS and JavaScript code, no coding knowledge required, you have have to know the basics of editing HTML templates. All you are going to do is basic copying-pasting.




The new year is just hours away so without wasting much time let's get on with the tutorial.

Before we begin, here's a quick demo of what you will be adding: Demo Hosted on JSBin

The code that you need

The new message is basically an image that is shown interactively using JavaScript and the way it is displayed using CSS as well. The entire code here is a mixture of HTML, CSS and JavaScript code.

Copy the code:

<div class="new-year-message" id="stramaxon_new_year_message"></div>
<style>
.new-year-message {
display: none;
opacity: 0;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .5s all ease-in-out;
z-index: 99999;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizdj3FJait56mKMFM_iTeNZYt4jfI4Cqyx9ZG4TtdS16zwaYVyJ96MoIeuuH9Mr5a-DCkabCQUPJPveTIjqfZ6qVrx7E0DMS1kgj0Vwn6lVHZB4ih_REe-icnX6lCPJj-PCTFPy91DjKeA/s1600/happy-new-year-3-t.jpg");
}
</style>

<script>
document.addEventListener("DOMContentLoaded", function(){
var seconds = 5; // Number of seconds you want the message to be visible
var show = true;
var message = document.getElementById("stramaxon_new_year_message");

// Check if the message has been shown before
if ( window.localStorage ) {
if ( !localStorage.getItem("stramaxonNewYearMessage") ) {
show = true;
}
else {
show = false;
}
}

// Show and click to close
if ( show ) {
_fadeIn( message );

setTimeout(function(){
_fadeOut( message );
}, seconds * 1000 );

if ( window.localStorage ) {
localStorage.setItem("stramaxonNewYearMessage", "shown")
}
}
else {
// don't show
}
message.addEventListener("click", function(){
_fadeOut(this);
});
});

function _fadeOut(el){
el.style.opacity = 1;
(function fade() {
if ((el.style.opacity -= .1) < 0) {
el.style.display = "none";
} else {
requestAnimationFrame(fade);
}
})();
};

function _fadeIn(el, display){
el.style.opacity = 0;
el.style.display = display || "block";
(function fade() {
var val = parseFloat(el.style.opacity);
if (!((val += .1) > 1)) {
el.style.opacity = val;
requestAnimationFrame(fade);
}
})();
};

</script>

Add it to your blog

After you have copied the entire code, the next step is to add it to your blog to actually display the new year message on your blog. 

The easiest and safest method to add a new block of code on a Blogger blog is to add it using an HTML/JavaScript widget, follow the steps to add one to your blog:
  1. Log-into your Blogger dashboard
  2. On your blog's dashboard, go to the Layout section
  3. In the sidebar or a footer section, you may see "Add a Gadget" link, click open it
  4. In the list of gadgets you will find "HTML/JavaScript" to add it click on the plus icon next to it. 
  5. You will now see a text-box under "Content", this is where you have to paste the copied code. Leave the "Title" field empty since we do not want the widget box to be apparently visible on the blog.


  6. Hit "Save" and that's it. 
You have successfully added the code that was required to add a simple, fade-in fade-out new year message on your blogger blog. 

I want a different image

As promised we will be providing a set of images that you can use depending on your blog's style and your taste. It is fairly easy to change which image you want to show. 

  1. In the code that you pasted in the HTML/JavaScript gadget, find the following line

    background-image: url("https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEizdj3FJait56mKMFM_iTeNZYt4jfI4Cqyx9ZG4TtdS16zwaYVyJ96MoIeuuH9Mr5a-DCkabCQUPJPveTIjqfZ6qVrx7E0DMS1kgj0Vwn6lVHZB4ih_REe-icnX6lCPJj-PCTFPy91DjKeA/s1600/happy-new-year-3-t.jpg");

  2. As the name suggests it tells the browser which image to load. The URL inside url() is the link to the image we are using. All you have to do is replace it with the URL of the image you would like to use. 
Here are the links to four different images that we prepared for you to use (right click on the link and copy link address):

Why I don't see it?

If you added the codes properly and you still can't see the message then it can be for two reasons:
  1. Either JavaScript is disabled in your browser. To fix it please look for ways to enable JavaScript in the browser you are using. 
  2. In case you only were able to see it for the first time you loaded your blog and it doesn't show up after that, then it is not a problem, as the message is set to display only once for a person. You do not want to obstruct a reader's experience every time they visit a different page on your blog with the same message banner. If you just want to check how it looks then fire up a Incognito or Private browsing mode in your browser and load the blog. 

That's it. We hope you find this useful and also wish you a very happy new year! 

See you in 2018. 

New Year, A New Beginning for StramaXon and Me

I started this blog back in the year 2011 when I was still a young enthusiast who had a craze for creating, creating just about anything that he found to be useful for people, to share what he knew and to help and connect with people.


Over these years many things changed, the blog itself went through a lot of make-overs. The content however remained pretty much same in nature - to share the knowledge I have with you all.

Starting with Blogger, I stepped into even broader topics, like web design itself though I always wanted this blog to be only about one topic but I soon found out it was neither wise nor good for the blog itself.

Many tutorials were posted on this blog, everything about Blogger. In the past couple of years, I however failed to write much, a lot of things kept me occupied, academic and work related as well as personal reasons.

I was unable to do for most of the part during the last couple of years and that was to write blog posts here. Somewhere during that time I wanted to start writing blogs again but I was too busy on web development / designing work I had forgot what Blogger was (not in its literal sense!), to be able to write about something you had to be consistent in using that, finding out what needed to covered, but I was unable to do so and that resulted in many many months of no blog posts.

Though, that's the story of past, a new year is awaits. We all know new year's resolutions don't turn out to be great as always, though in this case my new resolution is about something that I love - to write blogs and help people, and this is what I am going to do in 2018 and so on.

Most of the subscribers and readers of the blogs came here for Blogger related topics, and I am going to continue with Blogger and I am sure you will also love the content on topics ranging from Blogger to App Development. If you are a reader of this blog you may know that my blog posts even related to coding are very simplified and aimed at non-coders and that's what it is going to be with the new categories on the blog.

I hope you find my blog useful and find something new to learn. A lot of new content is coming and with it a new look for StramaXon!

Wish you all a very happy new year in advance.


Deepak Kamat