如何创建Facebook Like弹出框在点击之后关闭? [英] How to create Facebook Like popup box closes after hit the like button?

查看:76
本文介绍了如何创建Facebook Like弹出框在点击之后关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友们,



我使用以下代码创建了一个像弹出框一样的facebook:



 <  !DOCTYPE     html  >  
< html >
< head >
< meta charset = utf-8 / >
< title > 欢迎< / title >
< < span class =code-leadattribute> script src =' http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' < span class =code-attribute> type =' text / javascript' > < / script >
<! - Jquery代码 - >
< script type =' < span class =code-keyword> text / javascript' >
jQuery.cookie = function (键,值,选项){
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?' < span class =code-string>; path =' + options.path:' '
options.domain?' ; domain =' + options.domain:< span class =code-string>' '
options.secure?' ; secure'' '
] .join(' '));
}
options = value || {};
var 结果,decode = options.raw? function (s){ return s; }:decodeURIComponent;
return (result = new RegExp ' (?:^ |;)' + encodeURIComponent(key)+ ' =([^;] *)')。exec( document .cookie))? decode(结果[ 1 ]): null ;
};
< / script >
< script type =' text / javascript' >
jQuery( document )。ready( function ($){
if ($ .cookie(' popup_user_login')!= ' yes'){
$(' #popupwindow').delay( 1000 )。fadeIn(' 中等');
/ * 您可以根据自己的意愿更改弹出窗口的显示时间。注意:1sec = 1000 * /
$(' #imagepopup,#fan-exit' )。点击( function (){
$(' #popupwindow')。stop()。fadeOut(' medium');
});
}
/ * $ .cookie('popup_user_login','yes',{路径: '/',expires:7});默认情况下,Facebook Popup like框仅在用户访问您的页面时首次出现。如果您希望每次加载页面时都弹出facebook like框,则删除此行代码* /
});
< / script >
< style >
popupwindow {
显示 无;
背景 rgba(0,0,0,0.6); / * 设置窗口背景颜色* /
width 100%;
height 100%;
position 已修复;
top 0;
left 0;
z-index 99999;
}
backgroundsetting {
width 455px;
height 255px;
position relative;
background #FFFFF f; / * 设置弹出框背景颜色* /
top 20%;
left 2%;
< span class =code-attribute> margin
0px auto;
}
imagepopup {
cursor 指针;
背景 url(popupclose.png)repeat; / * 关闭图标网址* /
height 40px;
width 40px;
margin-top - 258px;
margin-left < span class =code-keyword> 413px;
position < span class =code-keyword> absolute;
}
< / style >
< / head >
< body >
< DIV id =' popupwindow' >
< < span class =code-leadattribute> div
id =' backgroundsetting' >
<! - 仅替换红色标记上的Facebook页面名称和Facebook页面ID - >
< iframe allowtransparency =' true' frameborder =' 0' < span class =code-attribute> 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;溢出:隐藏;宽度:450px;高度:250px;' > < / iframe >

< div id =' imagepopup' >
< / div >
< / div >
< / div >
< span class =code-keyword>< / body >
< / html >





我真正需要的是,如果用户点击了类似按钮,则弹出窗口想要自动关闭而不是单击关闭按钮...



任何人都可以帮我这样做..





提前致谢,

Priya

解决方案

){
if

.cookie(' popup_user_login')!= ' yes'){


' #popupwindow')。延迟( 1000 )。fadeIn(' medium');
/ * 您可以根据自己的意愿更改弹出窗口的显示时间。注意:1秒= 1000 * /


Hi friends,

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

<!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

解决方案

){ 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*/


这篇关于如何创建Facebook Like弹出框在点击之后关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆