Ni apa ceritanya kat sini?

Tutorial : Sorokkan Shoutbox Dalam Blog

Assalam pada korang semua. Sebenarnya, dah lama sangat aku tak buat tutorial khusus untuk blog. Jadi,  untuk kali ini, tutorial blog terbaru ini, ialah cara nak sorokkan 'kotak jerit' a.k.a shoutbox dalam blog. Hehehe.... Pada korang semua yang tak rela shoutbox blog korang dibiarkan 'terdedah', ataupun, kononnya, takut shoutbox penuh mesej SPAM, boleh la try tutorial ini. 

Bukan susah sangat! Cuma "Add a gadget", pastu "HTML/Javascript". Copy kod HTML kat bawah tu, dan paste kat kotak kosong "HTML/Javascript", kemudian edit apa-apa yang patut dan sesuai untuk blog korang, dan save! Itu jer! 

Ok, jom kita tengok koding dia! Yeahh!! 

Jenis "Slide", disorokkan kat sebelah kanan blog.


Jenis "Slide" 

<style type="text/css">
#gb{
position:fixed;
top:50px;
z-index:+1000;
}
* html #gb{position:relative;}

.gbtab{
height:100px;
width:30px;
float:left;
cursor:pointer;
background:url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMUk3FmWR9eY09WMO9Tww5uUIjj-XK2YA8b9WxBJ85-d0R89w7deXD6HXvi9RDpzjLB5I4HESroxMFhRWEJ2F6aVcBi9gI0gDqJeV9Dur5sep2R9RGbhYF3AF9EkuLBDMRAsGAk4M2tYxN/s320/tabs.png') no-repeat;
}
.gbcontent{
float:left;
border:2px solid #666666;
background:#F5F5F5;
padding:10px;
}
</style>

<script type="text/javascript">
function showHideGB(){
var gb = document.getElementById("gb");
var w = gb.offsetWidth;
gb.opened ? moveGB(0, 30-w) : moveGB(20-w, 0);
gb.opened = !gb.opened;
}
function moveGB(x0, xf){
var gb = document.getElementById("gb");
var dx = Math.abs(x0-xf) > 10 ? 5 : 1;
var dir = xf>x0 ? 1 : -1;
var x = x0 + dx * dir;
gb.style.right = x.toString() + "px";
if(x0!=xf){setTimeout("moveGB("+x+", "+xf+")", 10);}
}
</script>
<div id="gb">
<div class="gbtab" onclick="showHideGB()">   </div>
<div class="gbcontent">

MASUKKAN CODE SHOUTBOX KORANG KAT SINI

<div style="text-align:right">
<a href="javascript:showHideGB()">
[close]
</a>
</div>
</div>
</div>
<script type="text/javascript">
var gb = document.getElementById("gb");
gb.style.right = (30-gb.offsetWidth).toString() + "px";
</script>


[Sumber : anarm.net; text asal koding, lihat di SINI

Nota: Yang kaler BIRU tu, untuk setkan posisi shoutbox korang. Semakin tinggi nombor dia, semakin rendah la posisi shoutbox yang menyorok kat sebelah kanan tu! Tulisan MERAH tu, takkan korang tak faham pulak? Hihihi... 


Jenis "Ajax Popup Shoutbox". Bila button ditekan, ia akan keluar di tengah-tengah blog.


Jenis "Ajax Popup Shoutbox" 

<!-- Start Ajax Popup Shoutbox by iwan_redzuan -->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.pack.js"></script>

<script>
$(document).ready(function() {
//select all the a tag with name equal to modal

$('a[name=modal]').click(function(e) {

//Cancel the link behavior

e.preventDefault();

//Get the A tag

var id = $(this).attr('href');

//Get the screen height and width

var maskHeight = $(document).height();

var maskWidth = $(window).width();

//Set heigth and width to mask to fill up the whole screen

$('#mask').css({'width':maskWidth,'height':maskHeight});

//transition effect

$('#mask').fadeIn(1000);

$('#mask').fadeTo("slow",0.8);

//Get the window height and width

var winH = $(window).height();

var winW = $(window).width();

//Set the popup window to center

$(id).css('top', winH/2-$(id).height()/2);

$(id).css('left', winW/2-$(id).width()/2);

//transition effect

$(id).fadeIn(2000);

});

//if close button is clicked

$('.window .close').click(function (e) {

//Cancel the link behavior

e.preventDefault();

$('#mask').hide();

$('.window').hide();

});

//if mask is clicked

$('#mask').click(function () {

$(this).hide();

$('.window').hide();

});

});
</script>

<style>
img { border: none; }
#mask {

position:absolute;

left:0;

top:0;

z-index:9000;

background-color:#000;

display:none;

}

#boxes .window {

position:fixed;

left:0;

top:0;

width:440px;

height:200px;

display:none;

z-index:9999;

padding:20px;

}
#boxes #sitishoutbox {

background:url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDr2rRYhifw_gXKQ9Cd46dmPqRymbCG4PLRxh1Q9q63Gm26HsyXW_RHrfutNfBeH5ne1SdL3nif-Z6Q7H1z68Nx5NJZOpqzeJ1GsNbRm17MwgDoUKkjebP_rdg6vA02soUICEuciBvVus/s1600/pink.PNG) no-repeat 0 0 transparent;

width:272px;

height:460px;

padding:56px 0 20px 5px;

}
#closesb {

padding:2px 0 0 0;

}
#author {

padding:8px 0 0 168px;

}
</style>

<ul><center> <a href="#sitishoutbox" name="modal"><img src="http://i1039.photobucket.com/albums/a472/mijie88/Fail%20Blogspot/shoutboxtab.png" border="0" width="158" height="58" /></a> </center> </ul>

<div id="boxes">

<!-- Start Shoutbox -->

<div id="sitishoutbox" class="window">

MASUKKAN KOD SHOUTBOX ANDA

<div id="author"><a target="blank" href="http://lurvemyblog.blogspot.com/2010/12/tutorial-membuat-shoutbox-versi-ajax.html"/><img src="http://img.photobucket.com/albums/v486/mafiatrg/linky.png" /></a>

</div><div id="closesb"><input type="button" value="Close" class="close" />

</div></div><!-- End of Ajax Shoutbox -->
<!-- Mask to cover the whole screen -->

<div id="mask"></div></div>

<!-- End of Ajax Popup Shoutbox by iwan_redzuan -->


[Sumber kod : Siti Safiyyah

Nota:

1. Tukarkan perkataan "MASUKKAN KOD SHOUTBOX ANDA" dengan kod shoutbox korang sendiri.

2.Pastikan saiz shoutbox korang adalah seperti berikut: width = 261, height = 380. Caranya, tengok balik kat kod shoutbox korang, gunakan button Ctrl+F atau F3, cari perkataan "width" dan "height", dah jumpa, cuma ubah jer nombor selepas "width" dan "height", seperti yang dinyatakan di atas.

3. Kemudian, save.

4. Kalau nak tukar kaler frame shoutbox, gantikan link URL pada background:url. Atau pun, boleh juga korang rujuk kat SINI.

Kredit : Siti Safiyyah, Mijie dan Johari Hamzah


Selamat Mencuba !!!! 


No comments:

Post a Comment

Kalau sudi, jenguklah sini :)

Blog Ping

Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks
Related Posts Plugin for WordPress, Blogger...