Bien les comento, quiero hacer un popup cuando cargue la página, buscando encontre esta pagina que hace lo que necesito.
http://www.awesomepopup.com/test.html
Ya vi su codigo fuente y lo que creo que activa el popup es esto:
Código HTML:
<script src="http://www.awesomepopup.com/popup/awesomepopup.js"></script>
<BODY onLoad="checkCount(3)">
Ya me he descargado el awesomepopup.js
El problema es que al implementarlo en mi página, simplemente no hace nada, aca el código que implemente.
Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script type="text/javascript" src="http://jquery.com/src/latest/"></script>
<script type="text/javascript" src="greybox.js"></script>
<script type="text/javascript" src="awesomepopup.js"></script>
<link href="greybox.css" rel="stylesheet" type="text/css" media="all" />
<script type="text/javascript">
var GB_ANIMATION = true;
$(document).ready(function(){
$("a.greybox").click(function(){
var t = this.title || $(this).text() || this.href;
GB_show(t,this.href,470,600);
return false;
});
});
</script>
</head>
<body onLoad="checkCount(3)">
<p align="left"><font face="Trebuchet MS" size="5"><a href="codigo.html" title="Codigo de conducta" class="greybox" style="text-decoration: none"><font color="#CC0066">
Test</font></a></font></p>
</body>
</html>
Alguien que me ayude, porque ya me duele la cabeza.
Les agrego el código del .js. OJO le deje a que abra el mismo link que tiene el demo que les puse ... imagino eso no hara mucho daño.
Código:
<!-- Begin
var expDays = 0; // number of days the cookie should last
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
var page = "http://www.awesomepopup.com/popup/awesomepopup.html";
var PopupWidth = 500; //Change the PopupWidth to your requirements.
var ScreenWidth = screen.width;//Change to your available screen width.
document.write('<div id="a1">');
document.write('<div id="awesomePopup" style="display:none;">');
document.write('<div style="position: fixed;">');
document.write('<div id="myid" style="width:500px; height:400px;">');
document.write('<div style="width:500px;height=400px;">');
var frameheight = 400;
if (frameheight > 500) {
var frameheight = 500;
}
document.write('<iframe style="border:5px solid #FF6600;margin-top:0px;margin-left:0px;margin-right:0px;margin-bottom:0px" frameborder=0 border=0 width=500 height=' + frameheight + ' src="' + page + '"></iframe>');
document.write('</div>');
document.write('</div>');
document.write('</div>');
document.write('</div>');
document.write('</div>');
var SetPopup = document.getElementById("popup");
document.write('<div id="popup" style="visibility:hidden;z-index:4;width:'+PopupWidth+';position:absolute;"></div>');
function StartPopup(objC,c) {
SetPopup = document.getElementById("popup");
SetPopup.innerHTML = c.innerHTML
SetPopup.style.left = (screen.width - PopupWidth)/2 //getPos(objC,"Left");
var ScreenSize = getPos(objC,"Left") + PopupWidth;
if (ScreenSize > ScreenWidth) {
var scrOffsetC = getPos(objC,"Left") + PopupWidth - (ScreenWidth);
SetPopup.style.left = getPos(objC,"Left") - (scrOffsetC - 0);
}
SetPopup.style.top = 90; // getPos(objC,"Top") + objC.offsetHeight))/2;
SetPopup.style.visibility = 'visible';
document.body.innerHTML+='<div id="UpBck" style="position:absolute;width:'+ScreenWidth+';height:100%;top:0px;left:0px;background:#000000;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;">'
UpBck.style.visibility = 'visible';
document.body.style.overflow = "hidden";
}
function getPos(objC,sPos) {
var iPos = 0;
while (objC != null) {
iPos += objC;
objC = objC.offsetParent;
}
return iPos;
}
function CloseAwesomePopup() {
SetPopup = document.getElementById("popup");
SetPopup.style.visibility = 'hidden';
UpBck.style.visibility = 'hidden';
document.body.style.overflow = "auto";
}
function checkCount(delay) {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);
popdelay = delay; // time in seconds before popup opens
setTimeout('StartPopup(a1,awesomePopup)', popdelay*1000);
} else {
count++;
SetCookie('count', count, exp);
}
}
function checkCounts() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);
StartPopup(a1,awesomePopup);
} else {
count++;
SetCookie('count', count, exp);
}
}
function ShowPop(delay) {
popdelay = delay; // time in seconds before popup opens
setTimeout('StartPopup(a1,awesomePopup)', popdelay*1000);
}
// End -->
De ante mano gracias, y disculpen pero yo soy más de PHP ... XP