4
OK...
As hsalazar took the time to write a nice & long tutorial, I can take 5mins to translate that
(I also corrected it, as I think the original article has been written for XOOPS v1.x despite what its title says)
Skalpa.>
PS: Don't forget that if you let everything like that, the popup will be displayed again if an user comes back the next day. If, as I think considering your "chat" example, it's not what you want, I'd suggest you to save your orignal theme.html file so you can switch with / without popup as will.
---
Within the themes/yourtheme/theme.html, insert the following code just after the <head> tag:
<SCRIPT LANGUAGE="JavaScript">
function OpenPopup() {
// Check that the cookie isn't already there
if (GetCookie("pop")==null) {
// Create the popup window
window.open("<{$xoops_url}>/pop.html","pop","width=350, height=150, toolbars=no, scrollbars=no");
// Create a cookie that will last 24 hours
var pathname=location.pathname;
var myDomain=pathname.substring(0,pathname.lastIndexOf('/')) +'/';
var date_exp = new Date();
date_exp.setTime(date_exp.getTime()+(24*3600*1000)); // 24 heures
SetCookie("pop","ok",date_exp,myDomain);
}
}
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 getCookieVal(offset) {
var endstr=document.cookie.indexOf (";", offset);
if (endstr==-1)
endstr=document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
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;
}
</SCRIPT>
Then, call the function when the page loads by inserting this within the <body> tag:
<SCRIPT LANGUAGE="JavaScript">
OpenPopup();
</SCRIPT>
And last, create the page that will be displayed in your popup window, and save it at the root of your XOOPS site, using the filename you used earlier (in the above example, "pop.html"):
<HTML>
<TITLE>Pop</TITLE>
<BODY>
Content
</BODY>
</HTML>