Common Font Dialog (comdlg32.ocx) not working on Windows 7 calling from JavaScript in IE

1.6k Views Asked by At

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>
3

There are 3 best solutions below

0
On BEST ANSWER

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.

1
On

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)

0
On

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.