Click here to Skip to main content
16,009,255 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: (untagged)
Condition checking on like button of face book on page load
Posted
Comments
Nelek 18-Nov-13 9:28am    

1 solution

i made a fan gate using code below.it is working fine for website.when i used this code on facebook tab.it is not redirecting facebook page in javascript.my javascript code is given below:-




<script type="text/javascript">

$(document).ready(function() {
FB.login(function(response) {
if (response.status == 'connected') {
var user_id = response.authResponse.userID;
var page_id = "XXXXXXXX"; // coca cola page https://www.facebook.com/cocacola
var fql_query = "SELECT uid FROM page_fan WHERE page_id=" + page_id + " and uid=" + user_id;

FB.api('/me/likes/' + page_id, function(response) {
if (response.data[0]) {
//top.window.open("FirstPage.aspx", "_self");
//$("#container_like").show();
// document.getElementById("<% =btnUnlike.ClientID %>").click();
window.location.href("FirstPage.aspx");
} else {
//$("#container_notlike").show();
// document.getElementById("<% =btnLike.ClientID %>").click();
//top.window.open("Like.aspx", "_self")
window.location.href("Like.aspx");
}
});
} else {
// user is not logged in
}
});
});
</script>
 
Share this answer
 

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