chbcl Posted August 24, 2014 Report Share Posted August 24, 2014 Olá amigos, No meu website, pus esta pop-up: e este é o código: HTML: <div id="myModal" class="reveal-modal"> <h1>Ajuda-nos de uma forma simples!</h1> <p>Ao contrário da maioria dos websites da actualidade, nós não te obrigamos a partilhar videos ou a nossa página para que vejas as nossas postagens, a única coisa que pedimos é que ponhas like, uma coisa simples e que não custa nada a ninguém!</p> <p>Depois de pores gosto esta pop-up não voltará a chatear-te! Isso não é muito bom? kkk</p> <p>Ajuda-nos a crescer, o teu like vai ser um obrigado a nós pelo trabalho que temos. Não te custa nada!</p> <p><center><iframe src="//www.facebook.com/plugins/like.php?href=https://www.facebook.com/trollmasters.org&width&layout=button_count&action=like&show_faces=true&share=true&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:21px;" allowTransparency="true"></iframe></center></p> <p><i>Depois de clicares em Gosto clica em fechar para fazer desaparecer permanentemente esta pop-up chata e muito OBRIGADO </i></p> <p align='right'> <a href='' onclick='closebar(); return false'> [Fechar] </a> </p> </div> Javascript: <script type="text/javascript"> var persistclose=1 var startX = 20 var startY = 5 var verticalpos="fromtop" function iecompattest(){ return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body } function get_cookie(Name) { var search = Name + "=" var returnvalue = ""; if (document.cookie.length > 0) { offset = document.cookie.indexOf(search) if (offset != -1) { offset += search.length end = document.cookie.indexOf(";", offset); if (end == -1) end = document.cookie.length; returnvalue=unescape(document.cookie.substring(offset, end)) } } return returnvalue; } function closebar(){ if (persistclose) document.cookie="remainclosed=1" document.getElementById("myModal").style.visibility="hidden" } function staticbar(){ barheight=document.getElementById("myModal").offsetHeight var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera; var d = document; function ml(id){ var el=d.getElementById(id); if (!persistclose || persistclose && get_cookie("remainclosed")=="") el.style.visibility="visible" if(d.layers)el.style=el; el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";}; el.x = startX; if (verticalpos=="fromtop") el.y = startY; else{ el.y = ns ? pageYOffset + innerHeight : iecompattest().scrollTop + iecompattest().clientHeight; el.y -= startY; } return el; } ftlObj = ml("myModal"); stayTopLeft(); } if (window.addEventListener) window.addEventListener("load", staticbar, false) else if (window.attachEvent) window.attachEvent("onload", staticbar) else if (document.getElementById) window.onload=staticbar </script> O problema e que quero que ela apenas abra 1 vez por cada utilizador e nunca mais abra! Mas ela esta a abrir sempre que fecho o browser e volto a abrir -.- Não percebo quase nada de JS por isso o meu problema ainda nao ter resposta :s developer @ filipealves.net filipealvesbcl [a] gmail.com github.com/filipealvesbcl Link to comment Share on other sites More sharing options...
bioshock Posted August 24, 2014 Report Share Posted August 24, 2014 Fica uma sugestão: resolver com jQuery de forma fácil. $.get('responses/hasPopUp.php', function(aux){ var json = JSON.parse(aux); if(json.value == 0){ $('#myModal').modal('show'); } }); Do lado do PHP: echo json_encode(array("value" => (isset($_COOKIE['popup']) ? 1 : 0))); Link to comment Share on other sites More sharing options...
chbcl Posted August 24, 2014 Author Report Share Posted August 24, 2014 e isso fará com que não volte a aparecer? developer @ filipealves.net filipealvesbcl [a] gmail.com github.com/filipealvesbcl Link to comment Share on other sites More sharing options...
bioshock Posted August 24, 2014 Report Share Posted August 24, 2014 Sim. Por defeito o teu modal tem que estar escondido. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now