• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 322
  • Last Modified:

alert messages similars to messenger service

I would like to emulate the windows messenger services popups. This is: A javascript alert message with user IP adress, date and hour. I think is necessary first to detect the user info
with PHP or ASP for example, and then display the alert message.
0
rbbb
Asked:
rbbb
  • 3
  • 2
1 Solution
 
adktdCommented:
Hi rbbb
Tell me more of what you want to do.What you are saying is very general.You have to be more specific
0
 
rbbbAuthor Commented:
OK, I need to display randomly this kind of javascript alert messages:

function alertPopup1() {
alert("Message from HAPPY HOLYDAYS to 80.25.84.74 - 16/10/2003 10:15:36\n\nHello!\n\nThere is an incredible holydays offer on our page:     \n\nhttp://www.happyholydays.com/\n\nEnjoy the life!");
}

I also would like to display the messages with
a random delay of 2-30 min.

Thanks a lot for your help.
0
 
adktdCommented:
Here's an example :

<SCRIPT language="JavaScript">
<!--
function get_random(maxNum)
{
  if (Math.random && Math.round)
  {
    var ranNum= Math.round(Math.random()*(maxNum-1));
    ranNum+=1;
    return ranNum;
  }
  else
  {
  today= new Date();
  hours= today.getHours();
  mins=   today.getMinutes();
  secn=  today.getSeconds();
  if (hours==19)
   hours=18;
  var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
  return ranNum;
  }
}

function getaQuote()
{
 var maxQuotes=10;
 var whichQuote=get_random(maxQuotes);
 whichQuote--;

var quote=new Array(maxQuotes)
   quote[0]="Quote #1";
   quote[1]="Quote #2";
   quote[2]="Quote #3";  
   quote[3]="Quote #4";
   quote[4]="Quote #5";
   quote[5]="Quote #6";
   quote[6]="Quote #7";
   quote[7]="Quote #8";
   quote[8]="Quote #9";
   quote[9]="Quote #10";

alert(quote[whichQuote]);
}
//-->
</SCRIPT>
<FORM name="form1">
<INPUT TYPE="button" value="Get a Quote!" onClick="getaQuote()">
</FORM>  
0
 
rbbbAuthor Commented:
All right !! thank you so much. Only a question more about this script.
How can I display the user IP, date and hour in the text of these random alert messages?

Once more, thanks.
0
 
adktdCommented:
Ok here's how u'll do it.

-----for displaying the ip of the visitor :

<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->'

function ipval() {
document.myform.ipaddr.value=ip;
}
window.onload=ipval
</script>

<form method="post" action="" name="myform">
  <input type="text" name="ipaddr" readonly>
</form>

in order to get this function to work your web srver must run ssi(most web servers do that by default)

---for displaying the date :

<script language="JavaScript">
HoldDate=new Date();
document.write(HoldDate.getDate() + "/" + (HoldDate.getMonth()+1) + "/" + HoldDate.getYear());
</script>

---for displaying the time :
<script type="text/javascript">
var d = new Date()
document.write(d.getHours())
document.write(":")
document.write(d.getMinutes())
document.write(":")
document.write(d.getSeconds())
</script>

I'm giving you the general code of the scripts,u r the one that should put all these together.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now