Solved

alert messages similars to messenger service

Posted on 2003-11-03
7
313 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

771 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now