最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Uncaught TypeError: Cannot read property 'scrollHeight' of null - Stack Overflow

programmeradmin1浏览0评论

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: /

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

<script type="text/javascript" src=".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?

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?

Share Improve this question edited Apr 12, 2017 at 20:43 Sᴀᴍ Onᴇᴌᴀ 8,2838 gold badges37 silver badges60 bronze badges asked Apr 11, 2017 at 22:53 MatteoMatteo 311 gold badge1 silver badge3 bronze badges 2
  • 1 means the element you are referencing is not there... – epascarello Commented Apr 11, 2017 at 23:04
  • The script is looking for id pageContent which doesn't exist. – Christina Commented Apr 11, 2017 at 23:29
Add a ment  | 

1 Answer 1

Reset to default 2

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).

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.).

发布评论

评论列表(0)

  1. 暂无评论