Javascript activex动态加载
我有以下问题: 我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试:
我不会太频繁地使用多个框架,但这就是您处理另一个框架的方式。所涉及的框架是
iframe
并不重要。每个框架都有自己的window
对象。document
是该对象的一个属性。parent
指当前窗口
的父级,如果它已经是顶层,则指它本身。document.dwfFrame
会得到 id 为 dwfFrame 的元素,它与 iframe 的 window 对象不同。即使是这样,执行dwfViewer.ExecuteCommand('BLACKANDWHITE');
也会尝试将ExecuteCommand
作为 iframe 窗口的方法调用,而不是查看器对象。Try:
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 ownwindow
object. Thedocument
is a property of that object.parent
refers to the parent of the currentwindow
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, doingdwfViewer.ExecuteCommand('BLACKANDWHITE');
would try to callExecuteCommand
as a method of the iframe's window, not the viewer object.