Panning & zooming

Im following

I download it, uploaded it and heres the result
But when I tried to install ir on my computer, and all see is an image. When I went to inspect the element, I dont see the generated HTML like it does with to other on on the server… Is there some reason

tried to follow,

why is it not panning or zooming?

Hi @lurtnowski, if you open the console of the browser dev tools you see an

Uncaught TypeError: Cannot read property ‘addEventListener’ of null

at MBSE_zoom3.html:56; so it can’t find the zoom elements at this point. You have to put your JS at the end of the body so that the DOM is ready and can be queried when the script executes, not in the head.

1 Like

It works now, do I always put any JavaScript at the end of the body? Cause sometimes it says to put it in the head?

Yes that’s how I was taught too LOL. With a few exceptions (such as async analytics scripts) it’s best practice to place all your JS at the end of the body though; this way you don’t need to subscribe to events like the beloved $(document).ready(), and more importantly, the user doesn’t have to wait for your JS to load before they can see the page content.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.