This is the codes that i’ve have written, i’m new to javascript so there’s probably some easy mistakes and hopefully someone know how to fix it because at the moment the “alert” pops up even if you clicked the iframe. Feel free to ask if you want more info about code or what to know anything:)
<script language="javascript">
var value = false;
function openlink()
{
alert('yo');
}
function getIt()
{
if(value == true)
window.open('http://stackoverflow.com/','_self');
if(value == false)
alert("...");
}
</script>
<iframe onclick="javascript:value=true;" src="..." scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:350px; height:35px;" allowTransparency="true"> </iframe>
First of all you should never keep someone from browsing your site because some people like me don’t have a FaceBook, and therefor can’t LIKE your site. This is also really really poor SEO.
So, instead you can do this:
-User enters site first time
-user clicks a link
-set pop-up cookie = true & || set browser storage pop-up cookie = true
-pop-up with request to like the site
-user likes or doesn’t like the pop-up/site
-close box, forwards user along the link
-User enters with cookie & || browser storage set
– use link normally
Or, at the end of the day, you could just use the FB API – But again… you don’t want them to not be able to continue to use your site if they haven’t liked it.
-Get FB UserID
-Check FB API for if UserID has LIKE “myurl.com”