简体   繁体   中英

SCRIPT5022: SyntaxError in IE 11

I've got a webapp using Accusofts Prizm ActiveX Viewer to view and edit PDF's online. This product seems to work fine in every browser including edge except, you guessed it, Internet Explorer 11. I have been searching through the depths of the internet to try to find a solution to this and have found no useful results.

The error I am receiving is SCRIPT5022: SyntaxError with no further information on the error received which takes me to the following function with the 3rd line being the recipient of the error.

function createIconMap(iconText) { var parser = new DOMParser(); var iconDoc = parser.parseFromString(iconText, 'image/svg+xml');

I have ran and compared IE against chrome and both inspectors are informing me they are behaving the same. Yet IE brakes on this function and Chrome goes on to display the PDF.

Please see the full JS below

// createIconMap
// Given an SVG as a string, parse it and extract the content of all
// symbol elements with an id.
function createIconMap(iconText) {
    var parser = new DOMParser();
    var iconDoc = parser.parseFromString(iconText, 'image/svg+xml');
    var icons = iconDoc.getElementsByTagName('symbol');
    function attributeReducer(memo, attr) {
        return memo + ' ' + attr.name + '="' + attr.value + '"';
    }

    function childReducer(memo, node) {
        if (node.nodeType !== 1) {
            return memo;
        }

        // Build the DOM string of this node. Unfortunately, IE does
        // not implement innerHTML, outerHTML, or any of the other
        // content methods for SVG Elements and Node elements from
        // the DOMParser.
        return memo + '<' + node.tagName + ' ' +
            _.reduce(node.attributes, attributeReducer, '') +
            '>' +
            (node.childNodes.length ? reduceNode(node) : '') +
            '</' + node.tagName + '>';
    }

    function reduceNode(node) {
        return _.reduce(node.childNodes, childReducer, '');
    }

    _.forEach(icons, function (icon) {
        var id = icon.getAttribute('id');

        if (!id) {
            return;
        }

        ICON_MAP[id] = reduceNode(icon);
    });
}

    function Viewer(element, options) {

        this.$dom
            .html(_.template(options.template.viewer)(_.extend({
                reasons: this.redactionReasonsExtended,
                annotationsMode: options.annotationsMode,
                downloadFormats: downloadFormats,
                annotationFormats: annotationFormats
            }, PCCViewer.Language.data)))
            .addClass('pccv')
            .show();

        createIconMap(options.icons);
}

Please check the file (pdf, xml) content, might be the file contain the error description. More details, you could refer to this sample .

Besides, according to this thread , you could try to use ActiveX to parse documents.

So, here's what has been found out as time has gone on. I have since found out that the Accusoft product doesn't work on IE 11 (64 bit version) which is the only version available on Windows 8+. I have also determined that putting the following in a Try/Catch will help enable it to work part of the time

var parser = new DOMParser();
var iconDoc = parser.parseFromString(iconText, 'image/svg+xml');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM