Knowledge Base

Search the Knowledge Base: |
Search the Knowledge Base: |
Embedding Virtual Machines in Web Browsers
Details
Solution
Prerequisites
-
A cabinet file (CAB) to install VMware's MKS plug-in into Internet Explorer. Refer to
<hostname>/usr/lib/vmware/webAccess/tomcat/apache-tomcat-5.5.17/webapps/ui/plugin/msie/vmware-mks.cab
-
Cross-platform installer (XPI) to install VMware's MKS plug-in into Firefox (Windows and Linux).
-
For Linux, refer to
<hostname>/usr/lib/vmware/webAccess/tomcat/apache-tomcat-5.5.17/webapps/ui/plugin/mozilla/linux/vmware-mks.xpi -
For Windows, refer to
<hostname>/usr/lib/vmware/webAccess/tomcat/apache-tomcat-5.5.17/webapps/ui/plugin/mozilla/win32/vmware-mks.xpi
-
Embedding the Plug-In
The plug-ins can be embedded, in an HTML page, using the OBJECT tag as shown below.
Internet Explorer
<object id="mks" classid="CLSID:DC7D77DA-E1AC-4D40-930B-B87B2954E034" codebase="vmware-mks.cab#version=2,0,1,0" width="100%" height="100%"></object>
The <codebase > attribute specifies the location of the CAB file that may be downloaded to install the control.
Use the VBScript to check whether or not the plug-in is installed.
function isPluginInstalled() {
var MKS_PLUGIN_INSTALLED = false;
document.write('<scr' + 'ipt language="VBScript"
type="text/vbscript">
option explicit
on error resume
next
if(IsObject(CreateObject("QuickMksAx.QuickMksAxCtl.1"))
= false) then
MKS_PLUGIN_INSTALLED = false
else
MKS_PLUGIN_INSTALLED = true
end if
</scr' + 'ipt>');
return MKS_PLUGIN_INSTALLED;
}
Firefox
<object id="mks" type="application/x-vmware-mks;version=2.0.1.0" width="100%" height="100%"></object>
Use the navigator.mimeTypes object to check whether or not the plug-in is installed.
varisPluginInstalled = navigator.mimeTypes["application/x-vmware-mks;version=2.0.0.0"];
The plug-in can be easily installed by calling the install() function:
function install() {
var os = window.navigator.platform;
if (os.match(/Win32/)) {
window.frames["pluginDownload"].location.href =
'vmware-mks-windows-FF.xpi';
} else if (os.match(/Linux/)) {
window.frames["pluginDownload"].location.href =
'vmware-mks-linux-FF.xpi';
}
}
Note: Point location.href to a valid XPI location. Unlike Internet Explorer, Firefox uses the XPI to install the plug-in.
Scripting the Plug-In
Internet Explorer
< script language="Javascript" type="text/javascript"
// hostAddress -> ESX host name (fqdn) or the IP address.
// authdPort -> 902 (please make sure port 902 and 903 are open).
// vmCfgPath -> The VMX location (for the VM in question).
// uname -> A valid user name.
// password -> A valid password.
mks.connect(hostAddress, authdPort, vmCfgPath, uname, password);
</script>
Firefox
<script language="Javascript" type="text/javascript">
var mks = document.getElementById('mks'); // assuming the OBJECT tag ID is mks.
// hostAddress -> ESX host name (fqdn) or the IP address.
// authdPort -> 902 (please make sure port 902 and 903 are open).
// vmCfgPath -> The VMX location (for the VM in question).
// uname -> A valid user name.
// password -> A valid password.
mks.connect(hostAddress, authdPort, vmCfgPath, uname, password);
</script> Note: If you are using the VMware Infrastructure SDK then make all the connectionarguments available in the MksTicket object. Use same user name and password in the ticket field, in the MksTicket, and in the MKS connection.
Note: Refer to the IDL for a list of all the operations that can be performed on the control.
Capturing Events
Events fired by the control can be captured as follows.
Internet Explorer
-
Capture the connection state change event:
<script type="text/javascript" id="connState" for="mks"
event="OnConnectionStateChange(connected)">
// @ param connected = Type Boolean.
</script>
- Capture the window grab event:
<script type="text/javascript" id="grabState" for="mks"
event="OnGrabStateChange(grabState)">
// @ param grabState = Type Integer (1 => Grabbed,
2 =>Ungrabbed Hard, 3 => Ungrabbed Soft)
</script>
Capture the message event:
<script type="text/javascript" id="message" for="mks" event=
"OnMessage(type, message)">
// @ param type – Type Integer (0 => Hint, 1 => Info, 2 => Warn, 3 => Error)
// @ param message – Type String (The actual message from the control)
</script>
- Capture the Ctrl+Alt+Enter (to enter fullscreen mode) event:
<script type="text/javascript" id="grabState" for="mks" event="OnWindowStateChange(windowState)">
// @ paramwindowState – Type Integer (1 => Fullscreen, 2 =>Windowed, 3 => Enter Fullscreen)
// Note: With windowState == 1 the MKS will enter fullscreen automatically.
if (windowState == 3) {
mks.setFullscreen(true);
}
</script>
Firefox
language="JavaScript" type="text/javascript">
const IMessageListener = Components.interfaces.xpcomIMessageListener;
const IGrabStateListener =
Components.interfaces.xpcomIGrabStateListener;
const IWindowStateListener =
Components.interfaces.xpcomIWindowStateListener;
const IConnectionStateListener =
Components.interfaces.xpcomIConnectionStateListener;
Capture the connection state change event:
function ConnectionStateListener() {}
ConnectionStateListener.prototype = {
onConnectionStateChange : function (connected) {
...
}
},
};
- Capture the window grab event:
function GrabStateListener() {}
GrabStateListener.prototype =
{
onGrabStateChange : function (grabState) {
if (grabState == IGrabStateListener.GS_GRABBED) {
...
}
};
- Capture the message event:
function MessageListener() {}
MessageListener.prototype =
{
onMessage : function (msgType, message) {
if (msgType == IMessageListener.MT_HINT) {
alert(“Hey this is just a hint: “ + message);
}
}
};
- Capture the Ctrl+Alt+Enter (to enter fullscreen mode) event:
function WindowStateListener() {}
WindowStateListener.prototype =
{
onWindowStateChange : function (windowState) {
if (windowState == IWindowStateListener.WS_ENTER_FULLSCREEN) {
mks.setFullScreen(true);
}
}
};
</script>
Related Files
-
The CAB file for Intenet Explorer is available at
<hostname>/usr/lib/vmware/webAccess/tomcat/apache-tomcat-5.5.17/webapps/ui/plugin/msie/vmware-mks.cab
-
The XPIfile for Firefox (Windows) is available at
<hostname>/usr/lib/vmware/webAccess/tomcat/apache-tomcat-5.5.17/webapps/ui/plugin/mozilla/win32/vmware-mks.xpi
-
The XPI file for Firefox (Linux) is available at
<hostname>/usr/lib/vmware/webAccess/tomcat/apache-tomcat-5.5.17/webapps/ui/plugin/mozilla/linux/vmware-mks.xpi
-
The ActiveX control IDL, quickMksAx.dll , is included in the cab file.
- The Firefox plug-in IDL, xpcomIVMControl.xpt is included in vmware-mks.xpi .
- The ActiveX sample page, mkswinIE.txt , is attached to this article.
Additionally, samples are available in a zipped file attached to the Forum thread at https://www.vmware.com/community/thread.jspa?threadID=98422&tstart=0 .To view, log on to the community forum and select thread 98422.
- The Firefox sample page, mkswinFF.txt , is attached to this article.
Additionally, samples are available in a zipped file at https://www.vmware.com/community/thread.jspa?threadID=98422&tstart=0 .To view, log on to the community forum and select thread 98422.
Keywords
Attachments
Feedback
- KB Article: 1002342
- Updated: Aug 14, 2009
- Products:
VMware Infrastructure SDK - Product Versions:
VMware Infrastructure SDK 1.x
VMware Infrastructure SDK 2.0.x

