doufen3563 2017-04-11 22:53
浏览 1437

未捕获的TypeError:无法读取null的属性'scrollHeight'

There are a few conversation about this topic, but no one that really can help me.

Here is a page I am modifying, using Wordpress: http://www.cargo-websites.eu/demo-1/voorraad/

For a Javascript integration I am adding a script tag in the <head> tag of header.php:

<script type="text/javascript" src="http://voorraad.cargo-websites.eu/demo-1/voorraad/js/include.js"></script>

As soon as I add this code, the page returns the following errors:

Uncaught TypeError: Cannot read property 'scrollHeight' of null
at responseIt (include.js:5)
at window.onresize (include.js:4)
at Object.trigger (jquery.js:3)
at Object.a.event.trigger (jquery-migrate.min.js:2)
at jquery.js:3
at Function.each (jquery.js:2)
at a.fn.init.each (jquery.js:2)
at a.fn.init.trigger (jquery.js:3)
at theme.js:78
at theme.js:94

include.js:5 Uncaught TypeError: Cannot read property 'scrollHeight' of null
at responseIt (include.js:5)
at window.onresize (include.js:4)

And consequently, the header-img on that page has disappeared.

I found a"how to" for fixing the problem but it's far beyond my knowledge. How can I solve this issue?

  • 写回答

1条回答 默认 最新

  • dongtan7351 2017-04-11 23:29
    关注

    Looking at that line (5) of include.js, we see it begins with this code:

    var height=d.getElementById('pageContent').scrollHeight;
    

    That code attempts to access the scrollHeight property of whatever is returned by d.getElementById('pageContent'); (note that in line 4 - the start of the function responseIt(), d is assigned the value frame.contentWindow, where frame is assigned the value returned by document.getElementById('voorraadFrame') i.e. the DOM of the iframe with id="voorraadFrame").

    In your browser console, you should be able to add a breakpoint on line 5 and reload to inspect the value being returned (see image below where I did it in Google Chrome).

    chrome debugger

    In order for that to return a DOM element, the HTML of the page needs to contain an element like this:

    <div id="pageContent"></div>
    

    The tag name could vary (e.g. could be p, span, etc.).

    评论

报告相同问题?

悬赏问题

  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)