Click here to Skip to main content
15,881,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I've created one facebook like popup box using the following code:

HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Welcome</title>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' type='text/javascript'></script>
<!-- Jquery Code -->
<script type='text/javascript'>
jQuery.cookie = function (key, value, options) {
if (arguments.length > 1 && String(value) !== "[object Object]") {
options = jQuery.extend({}, options);
if (value === null || value === undefined) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '',
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
</script>
<script type='text/javascript'>
jQuery(document).ready(function($){
if($.cookie('popup_user_login') != 'yes'){
$('#popupwindow').delay(1000).fadeIn('medium');
/*You can change Popup window appearing time according to your wish. Note: 1sec = 1000*/
$('#imagepopup, #fan-exit').click(function(){
$('#popupwindow').stop().fadeOut('medium');
});
}
/*$.cookie('popup_user_login', 'yes', { path: '/', expires: 7 });By default, the Facebook Popup like box only first time appear when user visits your page. If you would like the facebook like box to popup every time when the page loads, then remove this line of code*/
});
</script>
<style>
#popupwindow {
display:none;
background:rgba(0,0,0,0.6); /*Set Window Background Color*/
width:100%;
height:100%;
position:fixed;
top:0;
left:0;
z-index:99999;
}
#backgroundsetting {
width:455px;
height:255px;
position:relative;
background:#ffffff; /*Set Popup box Background Color*/
top:20%;
left:2%;
margin:0px auto;
}
#imagepopup {
cursor:pointer;
background:url(popupclose.png) repeat; /*Close Icon Url*/
height:40px;
width:40px;
margin-top:-258px;
margin-left:413px;
position:absolute;
}
</style>
</head>
<body>
<div id='popupwindow'>
<div id='backgroundsetting'>
<!-- Only Replace Your Facebook Page Name and Facebook Page ID on Red Mark-->
<iframe allowtransparency='true' frameborder='0' scrolling='no' src="http://www.facebook.com/plugins/likebox.php?href=http://www.facebook.com/tarehub&width=200&height=346&colorscheme=light&show_faces=true&border_color&stream=false&header=false" style=' border:5px solid #005387; overflow: hidden; width: 450px; height: 250px;'></iframe>

<div id='imagepopup'>
</div>
</div>
</div>
</body>
</html>


In that what I really need is, if the user hit the like button then the popup window wanna to be close automatically instead of clicking the close button...

Anyone help me to do this..


Thanks in advance,
Priya
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900