Solved

alert messages similars to messenger service

Posted on 2003-11-03
7
318 Views
Last Modified: 2006-11-17
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
Comment
Question by:rbbb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 
LVL 1

Expert Comment

by:adktd
ID: 9670374
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
 

Author Comment

by:rbbb
ID: 9670457
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
 
LVL 1

Accepted Solution

by:
adktd earned 50 total points
ID: 9670497
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
 

Author Comment

by:rbbb
ID: 9671733
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
 
LVL 1

Expert Comment

by:adktd
ID: 9676918
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question