我的web應用程序(localhost:8083/myapp)在服務器端使用Java,在客戶端使用ExtJS 4.1.3,瀏覽器爲Google Chrome。
通過點擊我的web應用程序中的按鈕,我想用ActiveX對象打開新窗口。
我安裝了Neptune插件(http://www.meadroid.com/neptune/about.htm),它可以在Google Chrome中啓用ActiveX。我無法使用像IETab這樣的Chrome擴展程序,因爲它們會破壞我的標記,並且我不想在IE下加載整個應用程序。
手動安裝插件:將npmeadax.dll複製到C:\ Documents and Settings \ User_name \ Local Settings \ Application Data \ Google \ Chrome \ User Data \ Default \ Plugin Data,將其註冊到regsvr32.exe npmeadax.dll並重新打開谷歌瀏覽器。 注意:使用安裝程序自定義安裝後,npmeadax.dll可用。
插件只需要將embed標籤添加到屬性type ='application/x-meadco-neptune-ax'和屬性param-location設置爲location.href的頁面中。
問題是當我使用純HTML頁面時,ActiveX對象工作,但在Web應用程序中使用相同的代碼時不起作用。在純HTML頁面中,當我調試loadPage函數時,在窗口頂部出現tbody.appendChild(嵌入)信息欄並說:「爲了幫助保護您的安全,Internet Explorer限制此文件顯示可訪問您的活動內容電腦。點擊這裏查看選項。「我允許阻止內容,並且所有內容都按預期工作:字詞文件以字符串'Hello world!'打開。添加。但在Web應用程序中,activeX未激活。 /myapp//js/app/controller/somepackage/embed.html是相同的爲C:\ embed.html
這裏是普通的HTML頁面中的代碼:
C:\ button.html使用Neptune插件的Chrome在ExtJs應用程序中ActiveX不起作用
<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>
這裏是web應用程序中的代碼:
SomeForm.js(ExtJs的控制器):
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:
在JavaScript中添加純HTML頁面嵌入標籤 樣子:
<embed width="100%" height="100%" type="application/x-meadco-neptune-ax" param-location="file:///C:/embed.html">
在網絡應用程序中嵌入標籤的樣子:
<embed width="100%" height="100%" type="application/x-meadco-neptune-ax" param-location="http://localhost:8083/myapp//js/app/controller/somepackage/embed.html">