My web application (localhost:8083/myapp) uses Java on server side and ExtJS 4.1.3 on client side, browser Google Chrome.
By clicking button in my web application I want to open new window with ActiveX object.
I installed Neptune plugin (http://www.meadroid.com/neptune/about.htm), which enables ActiveX in Google Chrome. I can't use Chrome extensions like IETab because they break my markup, and I don't want to load the whole app under IE.
Manual installation of plugin: copy npmeadax.dll to C:\Documents and Settings\User_name\Local Settings\Application Data\Google\Chrome\User Data\Default\Plugin Data, register it with regsvr32.exe npmeadax.dll and reopen Google Chrome. Note: npmeadax.dll is available after custom installation with installer.
Plugin only needs embed tag to be added to a page with attribute type='application/x-meadco-neptune-ax' and attribute param-location set to location.href.
The problem is ActiveX object works when I use plain html pages, but doesn't work when I use the same code within web application. In plain html pages when I debug loadPage function, after tbody.appendChild(embed) information bar appears at the top of the window and says: "To help protect your security, Internet Explorer has restricted this file from showing active content that could access your computer. Click here for options." I allow blocked content and everything works as expected: word file opens with string 'Hello world!' added. But in web application activeX is not activised. /myapp//js/app/controller/somepackage/embed.html is the same as C:\embed.html
Here is the code for plain html pages:
C:\button.html
<html>
<head>
</head>
<body>
<input type="button" value="open win" onclick="window.open('embed.html','_blank')" />
</body>
</html>
C:\embed.html
<html>
<head>
<script type="text/javascript">
function loadPage() {
var lh = location.href;
var embed = document.createElement('embed');
embed.setAttribute('width','100%');
embed.setAttribute('height','100%');
embed.setAttribute('type','application/x-meadco-neptune-ax');
embed.setAttribute('param-location',lh);
var tbody = document.getElementsByTagName('body')[0];
tbody.appendChild(embed);
try {
var w = new ActiveXObject('Word.Application');
var docText;
var obj;
if (w != null)
{
w.Visible = true; //set to false to stop the Word document from opening
obj = w.Documents.Open("C:\\A.doc");
docText = obj.Content;
w.Selection.TypeText("Hello world!");
w.Documents.Save();
}
}
catch(e) {}
}
</script>
</head>
<body onload="loadPage()">
</body>
</html>
And here is the code within web application:
SomeForm.js (ExtJs controller):
Ext.define("App.controller.somepackage.SomeForm", {
extend : 'Ext.app.Controller',
...
init: function() {
this.application.on('click_button', this.onButtonClick, this);
...
},
onButtonClick: function() {
var win = window.open("/myapp//js/app/controller/somepackage/embed.html","_blank");
}
...
UPDATE:
in plain html page embed tag added in javascript looks like:
<embed width="100%" height="100%" type="application/x-meadco-neptune-ax" param-location="file:///C:/embed.html">
in web-application embed tag looks like:
<embed width="100%" height="100%" type="application/x-meadco-neptune-ax" param-location="http://localhost:8083/myapp//js/app/controller/somepackage/embed.html">
It seems that Neptune uses settings of current version of IE, which is installed in operating system. I use IE8, so I configured safety settings and everything worked fine - I got a dialog window asking about safety of ActiveX component. I have a localized version of IE, so I am sorry if I named something wrong. Here are the actions in IE:
1. Choose Service -> Explorer settings -> tab "Safety".
2. Choose "Local intranet". Click Nodes, then click Additional. Add
http://localhost
click Add, Close, then ОК.
3. Choose Another...
4. For "ActiveX elements and connection modules":
Automatic requests of ActiveX management elements - on
Run ActiveX elements' scripts marked as safe - on
Loading of unsigned ActiveX elements - suggest
Loading of signed ActiveX elements - suggest
Run ActiveX elements and connection modules - on
Usage of ActiveX elements not marked as safe for use - suggest
Action of binary code and scripts - on
Allow to use ActiveX without request only to asserted domains - off
Allow to run ActiveX management elements that was not used previously without warning - on
Allow scripts - on
After that I reopened Google Chrome.