Facebookの「いいね」ボタンをオーバーレイdiv(ページ下部)に表示したいのですが、複雑にする追加のリクエストがいくつかあります。
- 訪問者は、2ページ目のビューを生成するときにそれを見るでしょう(彼らはWebサイトにアクセスし、少なくとももう1ページを操作します)
- 一度だけ表示する必要があります
- 約20秒間(またはその他の秒数)、または「x」ボタンをクリックするまで表示されます。
- その前に短いテキストがあります(Example.comへようこそ...)。理想的には、ページから追加のDIVをプルせずに、すべてがこのコードに含まれます。
なんとか閉じるボタンを作成できました。これはコードです:
$(document).ready(function(){
$('#closebutton').click(function(){
$('#facebookdiv').remove();
$(this).remove();
document.cookie="removeit=yes";
});
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
x=x.replace(/^\s+|\s+$/g,"");
if (x=="removeit")
{
$('#facebookdiv').remove();
$('#closebutton').remove();
}
}
});
これとどのように達成できますか?これが私が実験しているいくつかのコードを含むjsFiddleです:http: //jsfiddle.net/tj8N6/3/
前もって感謝します!
編集
HTMLページのテストにおける私の現在のコード:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="http://http://code.jquery.com/jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.cookie('fbbox', '1', { path: '/', domain: 'www.example.com' });
if($.cookie('fbbox') == null) {
$.cookie('fbbox', '1', {expires:7, path:'/'});
}
if($.cookie('fbbox') == 1) {
$.cookie('fbbox', '2', {expires:7, path:'/'});
}
});
var buttonShowTime=20000;
if (fbbox == '2') {
$('#facebookdiv').show();
setTimeout(function() {
$('#facebookdiv').hide();
}, buttonShowTime);
}
</script>
</head>
<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/es_ES/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div id="facebookdiv">
<div class="fb-like" data-href="https://www.facebook.com/stackoverflowpage" data-send="false" data-width="450" data-show-faces="false" data-colorscheme="dark" data-font="arial"></div>
<div id="closebutton">X</div>
</div>
</body>
</html>