Protocols/MSNP/Activities/SDK/Techref/Promo/Code: Difference between revisions
Animadoria (talk | contribs) (Created automatically by Anima Importer) |
Animadoria (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
You can invoke the MSN® Messenger client directly from a Web page by adding script to the Web page. You can start by creating a new HTML page, or you can add script code to an existing HTML page. This script calls an | You can invoke the MSN® Messenger client directly from a Web page by adding script to the Web page. You can start by creating a new HTML page, or you can add script code to an existing HTML page. This script calls an ActiveX® control that invokes the MSN Messenger client application directly. You can design your script to pass two optional string variables to the ActiveX control, or if you prefer, you can pass either of the variables, or none. The variables that are passed to the ActiveX control are the AppID variable and the BOT variable. Both the AppID and the BOT variables are string variables, with the BOT variable being a string in the form of an e-mail address. In the code sample presented below, the BOT variable is assigned the emailID variable name.<br /> | ||
<br /> | <br /> | ||
The behavior of the MSN Messenger client when it is invoked depends on the following items: | The behavior of the MSN Messenger client when it is invoked depends on the following items: | ||
Line 12: | Line 12: | ||
* Which of the two variables you pass to the ActiveX control | * Which of the two variables you pass to the ActiveX control | ||
* The state of the MSN Messenger client at the time the MSN Messenger ActiveX control is called (whether the MSN Messenger client is active or not) | * The state of the MSN Messenger client at the time the MSN Messenger ActiveX control is called (whether the MSN Messenger client is active or not) | ||
* Which version of the MSN Messenger client or | * Which version of the MSN Messenger client or Microsoft® Internet Explorer browser is installed on the user's system | ||
</div> | </div> | ||
For more information about the effect of the variables on the behavior of the MSN Messenger client, see [[Protocols/MSNP/Activities/SDK/ | For more information about the effect of the variables on the behavior of the MSN Messenger client, see [[Protocols/MSNP/Activities/SDK/Techref/Promo/Variables|Using the MSN Messenger Variables]].<br /> | ||
<br /> | <br /> | ||
The main call that invokes the MSN Messenger ActiveX control is the following in the script area: | The main call that invokes the MSN Messenger ActiveX control is the following in the script area: | ||
Line 24: | Line 24: | ||
<pre class="clsCode"> | <pre class="clsCode"> | ||
obj.LaunchApp(AppID, emailID); | obj.LaunchApp(AppID, emailID); | ||
</pre> | </pre> | ||
Revision as of 00:21, 13 August 2022
Calling the MSN Messenger Client Directly
You can invoke the MSN® Messenger client directly from a Web page by adding script to the Web page. You can start by creating a new HTML page, or you can add script code to an existing HTML page. This script calls an ActiveX® control that invokes the MSN Messenger client application directly. You can design your script to pass two optional string variables to the ActiveX control, or if you prefer, you can pass either of the variables, or none. The variables that are passed to the ActiveX control are the AppID variable and the BOT variable. Both the AppID and the BOT variables are string variables, with the BOT variable being a string in the form of an e-mail address. In the code sample presented below, the BOT variable is assigned the emailID variable name.
The behavior of the MSN Messenger client when it is invoked depends on the following items:
- Which of the two variables you pass to the ActiveX control
- The state of the MSN Messenger client at the time the MSN Messenger ActiveX control is called (whether the MSN Messenger client is active or not)
- Which version of the MSN Messenger client or Microsoft® Internet Explorer browser is installed on the user's system
For more information about the effect of the variables on the behavior of the MSN Messenger client, see Using the MSN Messenger Variables.
The main call that invokes the MSN Messenger ActiveX control is the following in the script area:
obj.LaunchApp(AppID, emailID);
However, visitors with versions of Internet Explorer earlier than version 5.01 will not be able to access the MSN Messenger client. Similarly, if their version of the MSN Messenger client is earlier than version 6.2, this method will fail.
For this reason, it is important to add code that verifies the following:
- The visitor is using Internet Explorer 5.01 or later.
- The visitor is using MSN Messenger 6.2 or later.
In the first case, you should add a dialog box that plainly states that visitors' browsers do not support ActiveX controls. In the second case, you should add an error message that provides information that tells visitors that they need a later version of MSN Messenger.
The following sample code (in the script area) illustrates how to programmatically call the ActiveX control that invokes MSN Messenger:
<script type="JavaScript"> <!-- var obj; var winModalWindow; var AppID = "10331003"; var emailID = ""; //In the code variable declarations above, the AppID variable is assigned the value of the game Hexic (1003) for users //within the US (1033). You should substitute the correct value assigned to your application (by the Support team) //for your desired market. function TryItNow(AppID) { // Test #1: Launch with no email variable value causing the user to have to select another user to interact with. CheckMessenger(); LaunchApp(AppID, ""); } function LaunchApp(AppID, emailID) { if (obj != null) { obj.LaunchApp(AppID, emailID); } } function CheckMessenger() { eval ('try {obj = new ActiveXObject("MSNMessenger.P4QuickLaunch"); } catch (e) {obj = null;}'); var strErrorPage = "http://" + [HOSTNAME] + "/Error.aspx" if ([Browser is not IE]) { ShowWindow(strErrorPage, 410, 130); } else if (obj == null) { ShowWindow(strErrorPage, 410, 225); } } function IgnoreEvents(e) { return false } //Display error message if the MSN Messenger client 6.2 is not installed or the browser is not Internet Explorer function ShowWindow(strError, width, height) { if (window.showModalDialog) { window.showModalDialog(strError,null, "dialogWidth="+width+"px;dialogHeight="+height+"px;help=no;dialogLeft=160") } else { var ah = screen.availHeight; var y = (ah - height) / 2; window.top.captureEvents (Event.CLICK|Event.FOCUS) window.top.onfocus=HandleFocus winModalWindow = window.open (strError,"ModalChild", "dependent=yes,width="+width+",height="+height+",top="+y+",left=160,screenX=160,screenY="+y) winModalWindow.focus() } } function HandleFocus() { if (winModalWindow) { if (!winModalWindow.closed) { winModalWindow.focus() } else { window.top.releaseEvents (Event.CLICK|Event.FOCUS) } } return false } </script>