473,802 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making icon in taskbar flash

eragon
431 Contributor
hello good people. i have a chatroom on my website and i was looking for a script that would make the little icon for the browser flash when there is new activity, or make a popup, or something. is there a javascript code i can make that lets the browser know when there is activity. i use a div that is updated with AJAX to hold the content. when a new message is sent i would like to have something blink, a visual notification, and a little ding or some sound that would let people know somebody said something.

thanks
Nov 22 '07 #1
7 6087
acoder
16,027 Recognized Expert Moderator MVP
You can't make the icon flash, but you could play a sound (depending upon support and user preferences). Visual notification would have to be limited to within the browser, not outside.
Nov 23 '07 #2
eragon
431 Contributor
thats interesting, because i used meebo and when i get a message the button for firefox flashes. maybe its just really hard. on my page is a div tag that is updated with ajax, i would like to know how to play a sound when a new line is added to the div. can you help me?
Nov 23 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
There is one possibility: you could change the title repeatedly using setInterval.
Nov 25 '07 #4
eragon
431 Contributor
my title already flashes between my sites name and the short url, so i can add another, like, New Message, that will join the cycle and let me know, but i am not ajax savvy and have absolutely no clue on earth how to detect more information in the box. maybe find a difference of scroll height? and how does it know when i view the messages? i could put a onClick in my text entry field... i dont know... thats why im asking for help. please?
Nov 25 '07 #5
acoder
16,027 Recognized Expert Moderator MVP
You know that it's updated when the Ajax object's readyState is 4.

What does your code look like? Can you post some of it?
Nov 26 '07 #6
eragon
431 Contributor
soyatinly... (its a large script)

[html]
<?php session_start() ;
if(!isset($_SES SION['userid'])) { exit; } ?>
<html>
<head>
<title>Ajax Chat 3.1 (Room 1)</title>
<style type="text/css">
#content {
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
}
<!--username styles goe here-->
</style>
<script type="text/javascript">
function moveToBottom()
{
var div = document.getEle mentById('chatw indow');
h = div.scrollHeigh t;
sh = div.scrollTop;
st = div.offsetHeigh t;
difference = h - sh;
alt = st + 50
if (difference > alt) {
} else {
div.scrollTop = h;
}
}

function forceToBottom()
{
var div = document.getEle mentById('chatw indow');
h = div.scrollHeigh t;
div.scrollTop = h;
}

var t
function timedCount()
{
t=setTimeout("m oveToBottom()", 200)
t=setTimeout("t imedCount()",20 0)
}
</script>
</head>
<body>



<div id="content" style="overflow :hidden;">
<div id="chatwindow " style="overflow :auto; height:300px; border: 1px solid #CCCCCC;" height="300px"> </div>
<input id="chatnick" type="hidden" value="<?php echo(''.$_SESSI ON['userid'].''); ?>">
Smilies and other options coming soon! &nbsp;<br>
<input id="chatmsg" type="text" size="60" maxlength="80" onkeyup="keyup( event.keyCode); timedCount();">
<input type="button" value="add" onClick="submit _msg(); timedCount();" style="cursor:p ointer;border:1 px solid gray;">
<input name="button" type="button" style="cursor:p ointer;border:1 px solid gray;" onClick="forceT oBottom();" value="&dArr;">
</div>

</body>
</html>

<script type="text/javascript">

/* Settings you might want to define */
var waittime=10;

/* Internal Variables & Stuff */
chatmsg.focus()
document.getEle mentById("chatw indow").innerHT ML = "<center><b><p> <p>Loading... </b></center>";

var xmlhttp = false;
var xmlhttp2 = false;


/* Request for Reading the Chat Content */
function ajax_read(url) {
if(window.XMLHt tpRequest){
xmlhttp=new XMLHttpRequest( );
if(xmlhttp.over rideMimeType){
xmlhttp.overrid eMimeType('text/xml');
}
} else if(window.Activ eXObject){
try{
xmlhttp=new ActiveXObject(" Msxml2.XMLHTTP" );
} catch(e) {
try{
xmlhttp=new ActiveXObject(" Microsoft.XMLHT TP");
} catch(e){
}
}
}

if(!xmlhttp) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}

xmlhttp.onready statechange = function() {
if (xmlhttp.readyS tate==4) {
document.getEle mentById("chatw indow").innerHT ML = xmlhttp.respons eText;

zeit = new Date();
ms = (zeit.getHours( ) * 24 * 60 * 1000) + (zeit.getMinute s() * 60 * 1000) + (zeit.getSecond s() * 1000) + zeit.getMillise conds();
intUpdate = setTimeout("aja x_read('chat.tx t?x=" + ms + "')", waittime)
}
}

xmlhttp.open('G ET',url,true);
xmlhttp.send(nu ll);
}

/* Request for Writing the Message */
function ajax_write(url) {
if(window.XMLHt tpRequest){
xmlhttp2=new XMLHttpRequest( );
if(xmlhttp2.ove rrideMimeType){
xmlhttp2.overri deMimeType('tex t/xml');
}
} else if(window.Activ eXObject){
try{
xmlhttp2=new ActiveXObject(" Msxml2.XMLHTTP" );
} catch(e) {
try{
xmlhttp2=new ActiveXObject(" Microsoft.XMLHT TP");
} catch(e){
}
}
}

if(!xmlhttp2) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}

xmlhttp2.open(' GET',url,true);
xmlhttp2.send(n ull);
}

/* Submit the Message */
function submit_msg(){
nick = document.getEle mentById("chatn ick").value;
msg = document.getEle mentById("chatm sg").value;

if (nick == "") {
check = prompt("please enter username:");
if (check === null) return 0;
if (check == "") check = "anonymous" ;
document.getEle mentById("chatn ick").value = check;
nick = check;
}

document.getEle mentById("chatm sg").value = "";
ajax_write("w.p hp?m=" + msg + "&n=" + nick);
}

/* Check if Enter is pressed */
function keyup(arg1) {
if (arg1 == 13) submit_msg();
}

/* Start the Requests! ;) */
var intUpdate = setTimeout("aja x_read('chat.tx t')", waittime);

</script>
[/html]

and theres another page, see next post
Nov 28 '07 #7
eragon
431 Contributor
contd.

[php]
<?php
session_start() ;
//$_SERVER['REQUEST_TIME'];
date_default_ti mezone_set('Ame rica/New_York');
/* author: chris at linuxuser.at
licence: GPLv2
*/

$fn = "chat.txt";
$maxlines = 180000;
$nick_length = 100;

/* Set this to a minimum wait time between posts (in sec) */
$waittime_sec = 0;

/* spam keywords */


/* IP's to block */
$blockip[] = "72.60.167. 89";

/* spam, if message IS exactly that string */
$espam[] = "ajax";

/* Get Message & Nick from the Request and Escape them */
$msg = $_REQUEST["m"];
$msg = htmlspecialchar s(stripslashes( $msg));

$n = $_REQUEST["n"];
$n = htmlspecialchar s(stripslashes( $n));

if (strlen($n) >= $nick_length) {
$n = substr($n, 0, $nick_length);
} else {
for ($i=strlen($n); $i<$nick_length ; $i++) $n .= "";
}

if ($waittime_sec > 0) {
$lastvisit = $_COOKIE["lachatlv"];
setcookie("lach atlv", time());

if ($lastvisit != "") {
$diff = time() - $lastvisit;
if ($diff < 5) { die(); }
}
}

if ($msg != "") {
if (strlen($msg) < 2) { die(); }
if (strlen($msg) > 3) {
/* Smilies are ok */
if (strtoupper($ms g) == $msg) { die(); }
}
if (strlen($msg) > 150) { die(); }
if (strlen($msg) > 15) {
if (substr_count($ msg, substr($msg, 6, 8)) > 1) { die(); }
}

foreach ($blockip as $a) {
if ($_SERVER["REMOTE_ADD R"] == $a) { die(); }
}

$mystring = strtoupper($msg );
foreach ($spam as $a) {
if (strpos($mystri ng, strtoupper($a)) === false) {
/* Everything Ok Here */
} else {
die();
}
}

foreach ($espam as $a) {
if (strtoupper($ms g) == strtoupper($a)) { die(); }
}

$handle = fopen ($fn, 'r');
$chattext = fread($handle, filesize($fn)); fclose($handle) ;

$arr1 = explode("\n", $chattext);

if (count($arr1) > $maxlines) {
/* Pruning */
$arr1 = array_reverse($ arr1);
for ($i=0; $i<$maxlines; $i++) { $arr2[$i] = $arr1[$i];
}
$arr2 = array_reverse($ arr2);
} else {
$arr2 = $arr1;
}

$chattext = implode("\n", $arr2);

if (substr_count($ chattext, $msg) > 2) { die(); }
//Now we add the time:
$today = date("g:i A");

$out = $chattext . "<font class=\"".$_SES SION['userid']."\">[".$today."] " . $n . ":</font> " . $msg . "<br>\n";
$out = str_replace("\' ", "'", $out);
$out = str_replace("\\ \"", "\"", $out);

// lovely smilies :)
$raw = array(
":)",
":(",
";)",
":o",
":@",
"-.-",
":D",
">.>",
":,("
);
$happy = array(
"<img src=\"../images/smile/1.gif\" />",
"<img src=\"../images/smile/2.gif\" />",
"<img src=\"../images/smile/5.gif\" />",
"<img src=\"../images/smile/3.gif\" />",
"<img src=\"../images/smile/6.gif\" />",
"<img src=\"../images/smile/8.gif\" />",
"<img src=\"../images/smile/4.gif\" />",
"<img src=\"../images/smile/9.gif\" />",
"<img src=\"../images/smile/7.gif\" />"
);
$outs = str_replace($ra w, $happy, $out);

$handle = fopen ($fn, 'w'); fwrite ($handle, $outs); fclose($handle) ;
}
?>
[/php]
yay php. this one is the trimmer that cleans up the posts. if you want i would be more than happy if you cleaned it up, also, if you made a way to have multiple rooms in onw by setting a get paramatre in cht.php so it writes to a different text file. also, how do i get ajax to stop refreshing my smilies every second, it gets annoying... thanks!
Nov 28 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3234
by: Morten Bendsen | last post by:
Is it possible to set the icon and title for a group of buttons on the taskbar? The group appears when several applicationwindows are opened, and when "Group similar taskbar buttons" are checked at the taskbar properties page. Some default windows icon are used, unles I set the application icon in my vs project file. But I would like to set the icon at runtime.
5
4331
by: Dave | last post by:
Hi I am trying to set my windows xp pro system up so that i can write and test ..asp pages.I have followed the instructions given by www.w3schools.com to install the internet information services components. however, it says that I should then get an icon for ISS on the taskbar that will allow me to press 'start' so that my asp pages will work, but I have no such icon. I have tried reinstalling several times but with no change. Can...
0
1187
by: Huw Lloyd | last post by:
I am trying to develop a small VB.NET server application that runs in the background and places an icon in the Windows Taskbar. When the user double clicks on the taskbar icon the application window should appear and when they minimise, it should minimise back to the task bar... Any ideas how I do this?
3
6933
by: jm | last post by:
Hi, I have a C# program that changes the notifyIcon during the program. What I have noticed is that sometimes when the program is over the old icon will still be in the system tray. But when i move over the icons in the taskbar the taskbar will immediately update itself and clear the old icon away. I was just wondering if this is normal or if I am supposed to "force" an update of the taskbar system tray icons somehow?
2
2438
by: Brian | last post by:
Dear my friends, I have been helped by many C# gurus here, thank you very much. My small application can help you fetch some good pictures from Internet. You can get it from http://members.rogers.com/5725brian/i_want_images/IWantImages1.0.zip. No virus guarantee, nothing will harm your computer, trust me. Have fun to use it. But I still have some simple questions. When I run this program, it will display a icon on taskbar. But this...
0
1779
by: Jean Bredeche | last post by:
Hi: My application creates multiple forms, all of which appear in the taskbar. Because I have my Windows XP configured to "Group similar taskbar buttons", the multiple forms get put into the same group on the taskbar. Two problems I am running into: 1) the icon - each form's icon is correct, but when stacked in a group,
0
4055
by: Richard | last post by:
Hi All, I'm running MySQL 5.0.15-nt over WinXP-Pro/SP2. I just got "My Definitive Guide to MySQL 5", which I find very helpful. It suggests that there should be a "MySQL" icon in the Taskbar.I see none. It suggested unchecking the "Hide inactive icons" in the TaskBar Properties dialog. I followed that suggestion, but it only did by
2
5378
by: flaper87 | last post by:
Hi everybody!!!! I am developing an aplication, and i want it to stay on the system tray, i found out how to put the icon, but i can minimize it there, What do i have to do?, I'm using python(of course). and this is the code: # -*- coding: iso-8859-1 -*- # Don't modify comment import wx
1
10493
by: meagain | last post by:
How can I let the browser icon/button blink in the taskbar to alert a user that (f.e.) he has an new message when his browser-window is not focused or minimized?? Working with a flash-movie with a sound is not an option, neither is a alert() or confirm() ... Thanks!!
0
9699
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9561
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10281
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10058
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9111
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7597
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6835
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4270
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3789
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.