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
Solved

alert messages similars to messenger service

Posted on 2003-11-03
7
316 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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
installing and using WTP plugin eclipse MARS 3 124
File names with & character 6 81
JQuery tracking event. 3 79
Re-position sub-options beneath the TAB 7 98
Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logiā€¦
This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
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 the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

856 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