1
gruessle
Pop up window
  • 2003/10/8 1:51

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


Is it posible to have a window pop up at the user side.
I like to beable to send a message to online users.

Call them to the chat room or something like that.

2
skalpa
Re: Pop up window
  • 2003/10/8 3:09

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


Not easily...

The only thing you could do is modify your current theme file, so it displays your invitation somewhere, then remove your message after a while.

Displaying a popup to each user by this way would also be possible, but more difficult (you'd have to use a cookie so each user sees the popup only once).
Also, more and more people use anti pop-up software, so IMHO the "display within page" method is better.

Skalpa.>

3
hsalazar
Re: Pop up window
  • 2003/10/8 3:55

  • hsalazar

  • Just popping in

  • Posts: 78

  • Since: 2003/2/6 1


gruessle:

You can find the code to display a popup window here:

Popup dans XOOPS V2

It's in French but easy to follow. It does imply the creation and reading of a cookie, and you can easily change the duration of this cookie (the default is one day), so the popup doesn't annoy the user.

Cheers.

4
skalpa
Re: Pop up window
  • 2003/10/8 6:25

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


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 (namevalue) {
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(offsetendstr));
}
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(ij)==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>


5
gruessle
Re: Pop up window
  • 2003/10/8 7:34

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


Well this will as I understand pop up a window when someone logs in.

What I would like is to send someone a message when they are already loged in and I deside I like to talk to them in the chat room.

A one time message to one user selected by user name.

It would probably be even better to have the message diplayed on a block.
But I don't want everybody to get that message just one selected user.

6
gruessle
Re: Pop up window
  • 2003/10/8 10:15

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


That's OK I am just going to use the block future of the chat.

It is about time someone makes a Java Chat module.

7
heyula
Re: Pop up window
  • 2013/11/12 11:54

  • heyula

  • Theme Designer

  • Posts: 590

  • Since: 2008/4/24


Xoops Js Popup window Cokie

http://xoopstasarim.com/modules/themes/item.php?itemid=8

Login

Who's Online

169 user(s) are online (120 user(s) are browsing Support Forums)


Members: 0


Guests: 169


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits