首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ActiveX仅在IE9控制台被激活时才能工作

ActiveX仅在IE9控制台被激活时才能工作
EN

Stack Overflow用户
提问于 2015-01-14 14:43:05
回答 1查看 288关注 0票数 2

我正在构建一个小型web应用程序,它需要通过ActiveX和Javascript (和IE9.)访问Powerpoint。若要自动生成报表,请执行以下操作。我使用ActiveX是因为我无法在服务器端生成Powerpoint文件(尽管我非常喜欢这样)。

当我刚刚开始的时候,我的代码非常简单:

代码语言:javascript
复制
// 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);

在我的计算机上,ActiveX控件不启动Powerpoint,即使我允许它通过"An ActiveX control on this page might be dangerous; Do you allow it to execute?"执行(直接从法语导出)。

但是,如果我启动Developper控制台,它就会神奇地运行。而且,在另一台带有IE11的计算机上,在我允许ActiveX控件执行之后,它可以正常工作。

我认为我的IE安全设置是正确的,因此我想不出任何其他我不知道的IE故障。我正在使用IE9.0.8112.16421 64位。

,我怎么能让这段代码运行得很好呢?,谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-01-14 14:54:53

提醒: IE中的console.log只在开发者控制台打开时才能工作。如果开发人员控制台关闭,它将停止脚本,因为consoleundefined

在代码中,尝试更改:

console.log("ActiveX Object created");

使用

try{console.log("ActiveX Object created")}catch(err){}或用://注释行。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/27945553

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档