20/06/2011, 15:00
|
| | Fecha de Ingreso: junio-2011
Mensajes: 1
Antigüedad: 13 años, 5 meses Puntos: 0 | |
Respuesta: Popup lightbox automatico al iniciar un sitio Mi pregunta es este Code lo copio como un archivo de Java Script, que nombre le puedo poner para que lo reconosca el body en el index, puede ser el index un html Cita:
Iniciado por timz el js es este Código PHP: <!-- 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 = "AQUI VA LA RUTA";
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 -->
y en el body se coloca Código PHP: <BODY onLoad="checkCount(3)">
checkCount(3) (3) es el tiempo en segundos, puedes colocarle 0 si deseas.....
bueno eso es todo :P |