The Stickybar or fixed Bar that we released was
warmly welcomed. What we all have been searching for was a Close Button
or Cancel button that would hide the bar display. May be not every
visitor enjoys viewing that fixed bar at the top, so they deserve to be
provided with an option to view or hide the bar. While viewing one of
the Wordpress Blogs I found this button next to their updates bar. I
managed somehow to fetch the script half broken. Making it work with
blogger template was difficult because blogspot templates are programmed
via XML and the rules of XML are really harsh when it comes to
Character case. Debugging the script was difficult but Alhamdulillah the
hard work paid off. You can see it Live just to the right of my
Stickybar at the top. I am excited to share it with you all. Lets get to
work!
7. Save your template
8. You are all done!
Visit your blog to see it fixed to the top just beautifully with a close button waiting to be clicked!
Create a Sticky Bar With Close Button in Blogger
Follow these easy steps:
1. Go To Blogger > Design > Edit HTML
2. Backup your template
3. Search for this ]]></b:skin>4. Just above it paste the following CSS code,
#mbt_bar{5. Next search for </head> and paste the following Javascript code just above it
background:#333 url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhAiO5JnqXUX4le1vnbZmDPX824GwdFtouDafrbksnO51OgFauvr39zFGxeTFYn9NCyNvyJtcTC4uSc0zvLGs6D2fj7N0yFStxvztQuXYJps9g8IDgGDTjXWAylcXlwcs0a7bUtKC1BiIo/s400/stickybar.png') repeat-x;
width:100%;
margin:0 auto;
text-align:center;
padding:0px 0;
border-bottom: 1px solid #888888;
-moz-box-shadow: #666666 0px 1px 3px;
-webkit-box-shadow: #666666 0px 1px 3px;
box-shadow: #666666 0px 1px 3px;
z-index: 999;
height: 28px; position:fixed;
line-height: 1.85em;
vertical-align: baseline;
letter-spacing: 1px;
color:#fff;
font-size:13px;
font-weight:bold;
font-family: arial,"Helvetica",sans-serif;
}
#mbt_bar a{
text-decoration:underline;
color:#E2E504;
}
#mbt_bar a:hover{
text-decoration:none;
}
#mbt_bar p {margin:0; list-style:none;}
#mbt_bar img {vertical-align: middle;
margin-right: 6px;}
6. Finally search for <body> and just below it paste the following HTML code
<script type='text/javascript'>
//<![CDATA[
var mbt_arr = new Array();
var mbt_clear = new Array();
function mbtFloat(mbt) {
mbt_arr[mbt_arr.length] = this;
var mbtpointer = eval(mbt_arr.length-1);
this.pagetop = 0;
this.cmode = (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body;
this.mbtsrc = document.all? document.all[mbt] : document.getElementById(mbt);
this.mbtsrc.height = this.mbtsrc.offsetHeight;
this.mbtheight = this.cmode.clientHeight;
this.mbtoffset = mbtGetOffsetY(mbt_arr[mbtpointer]);
var mbtbar = 'mbt_clear['+mbtpointer+'] = setInterval("mbtFloatInit(mbt_arr['+mbtpointer+'])",1);';
mbtbar = mbtbar;
eval(mbtbar);
}
function mbtGetOffsetY(mbt) {
var mtaTotOffset = parseInt(mbt.mbtsrc.offsetTop);
var parentOffset = mbt.mbtsrc.offsetParent;
while ( parentOffset != null ) {
mbtTotOffset += parentOffset.offsetTop;
parentOffset = parentOffset.offsetParent;
}
return mbtTotOffset;
}
function mbtFloatInit(mbt) {
mbt.pagetop = mbt.cmode.scrollTop;
mbt.mbtsrc.style.top = mbt.pagetop - mbt.mbtoffset + "px";
}
function closeTopAds() {
document.getElementById("mbt_bar").style.visibility = "hidden";
}
//]]>
</script>
<div id='mbt_bar'> WRITE YOUR TEXT HERE <span style='padding:0px; float:right'>To write an announcement, update news or notice to readers, just replace the yellow highlighted text with your message. If you wish to change the Close button image then simply replace the bolded black link with your button's link.
<img align='absmiddle' border='0' onClick='closeTopAds();return false;' src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPT0OS6Im7Ekh0rJ_zlciOTQcer3x0ES5KZHjiBV_jPk3dxuY9BeHmsIZvmKKsdBWRyByxu7v1MgFy6GQLONTetQeSNWYw9CAiC5WD5div8DwTedt6b4kTjsd7TbudPqwXH0HpzqunLjs/s400/cancel.png' style='cursor:hand;cursor:pointer;'/></span></div>
<br/><br/>
7. Save your template
8. You are all done!
Visit your blog to see it fixed to the top just beautifully with a close button waiting to be clicked!
Thanks for this tips....
ReplyDelete