打开Web分析与Node.JS Web应用程序.获取错误'TypeError: doc is null'

Open Web Analytics with Node.JS web applicaiton. Getting Error 'TypeError: doc is null'

本文关键字:Web TypeError doc null is 获取 Node JS 打开 应用程序 取错误      更新时间:2023-09-26

场景:对于运行在Node.js上的web应用程序,我们正在集成OpenWebAnalytics。

问题:在firebug中,它显示如下错误

TypeError: doc is null
[Break On This Error]   
...dth?window.innerWidth:document.body.offsetWidth;viewport.height=window.innerHeig...

文件中的第1 168行owa.tracker.combined.min.js

方法源代码:

 getIframeDocument: function (iframe) {
        var doc = null;
        if (iframe.contentDocument) {
            doc = iframe.contentDocument;
        } else if (iframe.contentWindow && iframe.contentWindow.document) {
            doc = iframe.contentWindow.document;
        } else if (iframe.document) {
            doc = iframe.document;
        }
        if (doc == null) {
            OWA.debug("Document not found, append the parent element to the DOM before creating the IFrame");
        }
        doc.open();  // TypeError: doc is null
        doc.close();
        return doc;
    }

问题:有谁知道这种问题的解决方案吗?

谢谢你的帮助

在我的应用程序中配置开放web分析时,我遇到了同样的问题。问题可能是你在javascript片段

中提到的baseUrl

例如:不正确的var owa_baseUrl = 'http://yourdomain/path/to/owa';

正确:var owa_baseUrl = 'http://yourdomain/path/to/owa/';

再次检查嵌入在html文件中的javascript片段