通用字体对话框 (comdlg32.ocx) 在 Windows 7 上无法从 IE 中的 JavaScript 调用

发布于 2024-10-11 20:22:29 字数 2629 浏览 7 评论 0原文

我在 VB6 中使用表单应用程序尝试了字体对话框,它可以启动字体对话框,但是当我尝试在 javascript 中执行相同操作时,它失败并出现异常:

由于调用 ShowFont() 的行出现错误 800a8000,无法完成操作

这是我的 html 代码:有什么想法吗?

<html>
<head>
<title>test</title>
</head>

<script>

function doclick() {
        var fontDlg = document.all.fontDlg
  //var fontDlg = new ActiveXObject("MSComDlg.CommonDialog");

  /*
        cdlCCRGBInit = 1;
        cdlCCFullOpen = 2;
        cdlCCPreventFullOpen = 4;

        fontDlg.Flags = (cdlCCRGBInit | cdlCCFullOpen | cdlCCPreventFullOpen);
        fontDlg.CancelError = false;
        fontDlg.Min = 8;
        fontDlg.Max = 72;
        fontDlg.DialogTitle = "Change font settings";
        fontDlg.ShowFont();
        //fontDlg.ShowColor();
  */
  fontDlg.ShowFont();
}

</script>
<body>

<input type=button onclick=doclick() value="click me"/>

    <OBJECT id="fontDlg" style="LEFT: 224px; POSITION: absolute; TOP: 24px" classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB" CODEBASE="http://activex.microsoft.com/controls/vb5/comdlg32.cab #Version=1,0,0,0">
        <PARAM NAME="_ExtentX" VALUE="847">
        <PARAM NAME="_ExtentY" VALUE="847">
        <PARAM NAME="_Version" VALUE="393216">
        <PARAM NAME="CancelError" VALUE="0">
        <PARAM NAME="Color" VALUE="0">
        <PARAM NAME="Copies" VALUE="1">
        <PARAM NAME="DefaultExt" VALUE="">
        <PARAM NAME="DialogTitle" VALUE="">
        <PARAM NAME="FileName" VALUE="">
        <PARAM NAME="Filter" VALUE="">
        <PARAM NAME="FilterIndex" VALUE="0">
        <PARAM NAME="Flags" VALUE="0">
        <PARAM NAME="FontBold" VALUE="">
        <PARAM NAME="FontItalic" VALUE="">
        <PARAM NAME="FontName" VALUE="">
        <PARAM NAME="FontSize" VALUE="">
        <PARAM NAME="FontStrikeThru" VALUE="0">
        <PARAM NAME="FontUnderLine" VALUE="0">
        <PARAM NAME="FromPage" VALUE="0">
        <PARAM NAME="HelpCommand" VALUE="0">
        <PARAM NAME="HelpContext" VALUE="0">
        <PARAM NAME="HelpFile" VALUE="">
        <PARAM NAME="HelpKey" VALUE="">
        <PARAM NAME="InitDir" VALUE="">
        <PARAM NAME="Max" VALUE="0">
        <PARAM NAME="Min" VALUE="0">
        <PARAM NAME="MaxFileSize" VALUE="260">
        <PARAM NAME="PrinterDefault" VALUE="1">
        <PARAM NAME="ToPage" VALUE="0">
        <PARAM NAME="Orientation" VALUE="1">
    </OBJECT>
</body>
</html>

I tried the font dialog in VB6 with a form app and it could launch font dialog, but when I tried to do the same in javascript, it failed with exception:

Could not complete the operation due to error 800a8000

at line calling ShowFont().

Here is my html code: any ideas?

<html>
<head>
<title>test</title>
</head>

<script>

function doclick() {
        var fontDlg = document.all.fontDlg
  //var fontDlg = new ActiveXObject("MSComDlg.CommonDialog");

  /*
        cdlCCRGBInit = 1;
        cdlCCFullOpen = 2;
        cdlCCPreventFullOpen = 4;

        fontDlg.Flags = (cdlCCRGBInit | cdlCCFullOpen | cdlCCPreventFullOpen);
        fontDlg.CancelError = false;
        fontDlg.Min = 8;
        fontDlg.Max = 72;
        fontDlg.DialogTitle = "Change font settings";
        fontDlg.ShowFont();
        //fontDlg.ShowColor();
  */
  fontDlg.ShowFont();
}

</script>
<body>

<input type=button onclick=doclick() value="click me"/>

    <OBJECT id="fontDlg" style="LEFT: 224px; POSITION: absolute; TOP: 24px" classid="clsid:F9043C85-F6F2-101A-A3C9-08002B2F49FB" CODEBASE="http://activex.microsoft.com/controls/vb5/comdlg32.cab #Version=1,0,0,0">
        <PARAM NAME="_ExtentX" VALUE="847">
        <PARAM NAME="_ExtentY" VALUE="847">
        <PARAM NAME="_Version" VALUE="393216">
        <PARAM NAME="CancelError" VALUE="0">
        <PARAM NAME="Color" VALUE="0">
        <PARAM NAME="Copies" VALUE="1">
        <PARAM NAME="DefaultExt" VALUE="">
        <PARAM NAME="DialogTitle" VALUE="">
        <PARAM NAME="FileName" VALUE="">
        <PARAM NAME="Filter" VALUE="">
        <PARAM NAME="FilterIndex" VALUE="0">
        <PARAM NAME="Flags" VALUE="0">
        <PARAM NAME="FontBold" VALUE="">
        <PARAM NAME="FontItalic" VALUE="">
        <PARAM NAME="FontName" VALUE="">
        <PARAM NAME="FontSize" VALUE="">
        <PARAM NAME="FontStrikeThru" VALUE="0">
        <PARAM NAME="FontUnderLine" VALUE="0">
        <PARAM NAME="FromPage" VALUE="0">
        <PARAM NAME="HelpCommand" VALUE="0">
        <PARAM NAME="HelpContext" VALUE="0">
        <PARAM NAME="HelpFile" VALUE="">
        <PARAM NAME="HelpKey" VALUE="">
        <PARAM NAME="InitDir" VALUE="">
        <PARAM NAME="Max" VALUE="0">
        <PARAM NAME="Min" VALUE="0">
        <PARAM NAME="MaxFileSize" VALUE="260">
        <PARAM NAME="PrinterDefault" VALUE="1">
        <PARAM NAME="ToPage" VALUE="0">
        <PARAM NAME="Orientation" VALUE="1">
    </OBJECT>
</body>
</html>

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

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

发布评论

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

评论(3

吃不饱 2024-10-18 20:22:29

您的代码在什么安全上下文中运行?例如,在 IE 本身内部,或者托管 Web 浏览器控件的应用程序?如果是在 IE 中,您的页面运行在哪个安全区域?

出于安全原因,系统上的大多数 COM 对象都无法在 IE 中运行。

这可能并不重要,但您在函数的第一行中缺少分号

In what security context is your code running? E.g. inside IE itself, or an application hosting the web browser control? If it's in IE, what security Zone is your page running in?

Most COM objects on the system are prevented from running inside IE for security reasons.

(Not that it likely matters, but you're missing a semicolon in the first line of your function)

戈亓 2024-10-18 20:22:29

自从这样的代码被认为是一个好主意以来,IE 的安全模型已经取得了长足的进步。

如果幸运的话,您可以通过关闭 IE8 中的大量安全功能来使其正常工作。

IE's security model has moved on a long way since code like this was considered a good idea.

If you're lucky, you might be able to get it working by turning off a load of security features in IE8.

幼儿园老大 2024-10-18 20:22:29

我没有解决。我采纳了 Spudley 的建议并从我们的 Web 应用程序中删除了依赖项。相反,我只是制作了一个带有一些字体选项的 HTML 表单。容易得多,而且效果很好。

I didn't solve it. I took Spudley's advice and removed the dependency from our web application. Instead I just made a HTML form with some font options. A lot easier and it works fine.

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