Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript code to send a message to X msn user

Status
Not open for further replies.

Kharas

Programmer
Jan 30, 2007
39
0
0
MX
I am making a contact list for one of the websites I'm working on and given most of the users rely on a combination of AIM and MSN, I've run into this particular problem.

There is a javascript code which allows you to make a link that when clicked, (and if you have AIM open at the time) loads an AIM window addressing that X user with a default message like "Hello are you there". Here is the code:

Code:
<script language="JavaScript"> 

<!-- Begin 
function doAIM() { 
var action; 
var msg = document.frmAIM.txtMessage.value; 
var newMsg = ""; 
var charSpec = "N"; 
var specials = "&? @%"; 
for(var i = 0; i < msg.length; i++) { 
for(var q = 0; q < specials.length; q++) { 
if(msg.charAt(i) == specials.charAt(q)) { 
charSpec = "Y"; 
break; 
} else { 
charSpec = "N"; 
   } 
} 
if(charSpec == "Y") { 
newMsg += "+"; 
} else { 
newMsg += msg.charAt(i); 
   } 
} 
action = "aim:goim?screenname="; 
action += document.frmAIM.txtName.value; 
action += "&message="; 
action += newMsg; 
document.frmAIM.action = action; 
document.frmAIM.submit(); 
} 
//  End --> 
</script>

That's for the header and this is for the link itself:

Code:
<form method=post name="frmAIM"> 
ScreenName to Send to: <input type=text value="Screenname" onFocus="this.select();" name="txtName"><br> 
Message:<br> 
<textarea name="txtMessage" rows="5" cols="32" wrap="virtual">Geben Sie hier Ihre Nachricht ein!</textarea><br> 
<input type=button onClick="doAIM();" value="Send Message!"> 
</form> 
or<br> 
<br> 
<a href="aim:goim?screenname=Screenname&message=Hi,+Are+you+there?">Click</a>

However, I am concerned with doing exactly this in MSN. I'm unsure if you can go as far as adding a message, but at least being able to load the window addressing that X username, or adding the username to your messenger contacts list would be phenomenal.

Help is much appreciated.
 
I think developing applications with the SDK kit is a bit too extreme for this singular case. I don't forsee any 'improvements' for the website regarding this particular area. The automatic contact addition will be the only tool with a relation to msn, if we can even call it a 'tool'.

Thanks though Dian
 
I've been looking desperately all over the web and this is the only relevant info I found:


Where you are suggested to use an applet and then a simple a href:

Code:
<OBJECT classid="clsid:FB7199AB-79BF-11d2-8D94-0000F875C541" codeType=application/x-oleobject id=MsgrApp width=0 height=0></OBJECT>
<a href=javascript:MsgrApp.LaunchAddContactUI("dburgessjr2k2@hotmail.com")>AddContact</a>
<a href=javascript:MsgrApp.LaunchIMUI("dburgessjr2k2@hotmail.com")>SendMsg</a>

When applied upon a test page, you get an error upon loading and no response upon clicking.

I also found this, which was quite incomplete:


Code:
var objMsgr = document.getElementById("objMsgr");
	var status = objMsgr.MyStatus;
	if(!status)
	{
		alert("Some error accessing MSN Messenger (is it installed?)");
		return;
	}
	else if(status < 2)
	{
		alert("You are not logged in");
		return;
	}
	else
	{
		objMsgr.AddContact(0, name);
	}

Once more all help is greatly appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top