[英]ActiveX only working when IE 9 Console is activated
我正在構建一個小型Web應用程序,該應用程序需要通過ActiveX和Javascript(和IE9 ...)訪問Powerpoint才能自動生成報告。 我之所以使用ActiveX,是因為我無法在服務器端生成Powerpoint文件(盡管我本來非常希望這樣做)。
我剛開始時,我的代碼現在幾乎是一頭霧水:
// Creating the ActiveX Powerpoint control
var ppt;
try{
ppt = new ActiveXObject("Powerpoint.Application");
}catch(e){
if (e instanceof ReferenceError)
alert("Your browser might not be compatible with this function. Please use Internet Explorer.");
else
alert("An error happened: " + e);
}
console.log("ActiveX Object created");
// Openning Powerpoint, make it visible
ppt.Visible = 1;
// Creating a new Presentation, and adding a blank (1 slide, 1 = ppLayoutBlank) Slide
ppt.Presentations.Add();
ppt.ActivePresentation.Slides.Add(1, 1);
在我的計算機上,即使我允許通過"An ActiveX control on this page might be dangerous; Do you allow it to execute?"
執行"An ActiveX control on this page might be dangerous; Do you allow it to execute?"
Powerpoint,ActiveX控件也不會啟動Powerpoint "An ActiveX control on this page might be dangerous; Do you allow it to execute?"
(直接來自法語)。
但是,如果我啟動開發者控制台,它將神奇地運行。 並且,在另一台裝有IE 11的計算機上,在允許ActiveX控件執行后,它可以正常工作。
我認為我的IE安全設置是正確的,因此我無法想到我不知道的其他任何IE故障。 我正在使用64位IE 9.0.8112.16421。
我如何才能使此代碼正常運行? 先感謝您!
提醒:IE中的console.log
僅在開發者控制台打開時才有效。 如果開發者控制台關閉,則會停止腳本,因為console
undefined
。
在您的代碼中,嘗試更改:
console.log("ActiveX Object created");
同
try{console.log("ActiveX Object created")}catch(err){}
或用以下行注釋: //
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.