Javascript activex动态加载

发布于 2024-11-15 08:41:13 字数 1105 浏览 1 评论 0原文

我有以下问题: 我正在尝试使用 dwf 查看器应用程序,该应用程序由 activex 备份,允许在安装插件时查看 dwf 文件。

通常人们会像这样使用这个插件:

<object
classid = "clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF"
codebase = "http://www.autodesk.com/global/dwfviewer/installer/DwfViewerSetup.cab#version=6,0,0,200"
ID = "Eview"
width = "500"
height = "500"
border="0"></object>

然后只需调用这样的函数:

Eview.Viewer.ExecuteCommand("BLACKANDWHITE");
etc..

问题是我现在在服务器端的 Iframe 中创建对象:

<iframe id="dwfFrame" name="dwfFrame" src="plot.aspx" width="100%" height="100%" onload="initDWF()"/>

在plot.aspx 中我编写动态 dwf,然后在加载 iframe 时, activex 打开并且 dwf 显示正确。

   // Now output the resulting DWF.

    OutputReaderContent(Response, byteReader);

问题出在我的页面上,我无法进行 Javascript 调用,因为我没有对该对象的引用,我尝试将它们发送到 Iframe,但它不起作用。像这样:

dwfViewer = document.dwfFrame;
dwfViewer.Viewer.ExecuteCommand("BLACKANDWHITE");
dwfViewer.ExecuteCommand("BLACKANDWHITE");

我相信这是因为 iframe 不是实例化的 activex 对象,无论如何我可以获取这个对象以便我可以对其进行处理吗?

I have the following question:
I am trying to use a dwf viewer application, this is backuped by an activex that permits to view dwf files when the plugin is installed.

Usually one would use this plugin like this:

<object
classid = "clsid:A662DA7E-CCB7-4743-B71A-D817F6D575DF"
codebase = "http://www.autodesk.com/global/dwfviewer/installer/DwfViewerSetup.cab#version=6,0,0,200"
ID = "Eview"
width = "500"
height = "500"
border="0"></object>

then just call functions like this:

Eview.Viewer.ExecuteCommand("BLACKANDWHITE");
etc..

The thing is I am now creating the object in an Iframe by server side:

<iframe id="dwfFrame" name="dwfFrame" src="plot.aspx" width="100%" height="100%" onload="initDWF()"/>

in plot.aspx I write the dynamic dwf, and then when loading the iframe, the activex is opened and the dwf shown correctly.

   // Now output the resulting DWF.

    OutputReaderContent(Response, byteReader);

The problem is on my page I am unable to make Javascript calls cause I do not have a reference to the object, I tried issuing them to the Iframe but it doesn't work. Like this:

dwfViewer = document.dwfFrame;
dwfViewer.Viewer.ExecuteCommand("BLACKANDWHITE");
dwfViewer.ExecuteCommand("BLACKANDWHITE");

I beleive this is because the iframe is not the instancied activex object, is there anyway I could get ahold of this object so I can work on it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

独守阴晴ぅ圆缺 2024-11-22 08:41:13

尝试:

var dwfFrameDoc = parent.dwfFrame.document;
var dwfViewer = dwfFrameDoc.getElementById('Eview');

我不会太频繁地使用多个框架,但这就是您处理另一个框架的方式。所涉及的框架是 iframe 并不重要。每个框架都有自己的window对象。 document 是该对象的一个​​属性。 parent 指当前窗口 的父级,如果它已经是顶层,则指它本身。

document.dwfFrame 会得到 id 为 dwfFrame 的元素,它与 iframe 的 window 对象不同。即使是这样,执行 dwfViewer.ExecuteCommand('BLACKANDWHITE'); 也会尝试将 ExecuteCommand 作为 iframe 窗口的方法调用,而不是查看器对象。

Try:

var dwfFrameDoc = parent.dwfFrame.document;
var dwfViewer = dwfFrameDoc.getElementById('Eview');

I don't play around with multiple frames too often, but that is how you would address another frame. It shouldn't matter that the frame in question is an iframe. Each frame has its own window object. The document is a property of that object. parent refers to the parent of the current window or to itself if it is already the top level.

document.dwfFrame would get you the element whose id is dwfFrame, which is not the same as the window object of the iframe. Even if it were, doing dwfViewer.ExecuteCommand('BLACKANDWHITE'); would try to call ExecuteCommand as a method of the iframe's window, not the viewer object.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文