Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Player fails to load second time in lightbox

Hi I've been searching the web with no luck to this issue.

We are using JS player to play videos on our site. the video loads with a light box and works perfectly the first time the video is called. However if you try and call the video a second time the lightbox opens but no video appears. In the console I can see the following error:

There was an error calling back an event handler for "ready". Error: Cannot read property 'clientWidth' of null
jwpsrv.js:1 Uncaught TypeError: Cannot read property 'ownerDocument' of null.

I'm calling JWPlayer with the following bulk standard code.

var player = new jwplayer(div);

primary: 'html5',
file: video, // variable containing video url
width: size,
aspectratio: "16:9"

4 Community Answers


JW Player Support Agent  
0 rated :


Can you provide a test page?


0 rated :

I have now resolved this issue.

The issue is that on teardown of the lightbox I was deleting everything but the jwplayer object itself. So on the second click it was failing I assume because it was trying to reverence elements that no longer existed.

my tear down code is as follows:

destroy: function () {
jwplayer('overlay-video').remove(); //This is the important bit!
$('.overlay, .icon-close').off();

Note: this is mentioned deep in the api documentation but is not clear and so I feel easily missed.


JW Player Support Agent  
0 rated :

Hi Rob,

It’s good that you figured out the issue. It’s tough to account for all development scenarios, and yes sometimes it’s hard to navigate through all the volume of documentation available to find what you need. One of the issues of the internet these days. But yeah, if you need anything else, support is here.


0 rated :

Hi rob

You should to remove all the child elements from jwplayer div before you load new video.

var videoDiv= document.getElementById("overlay-video");
while (videoDiv.firstChild) {

This question has received the maximum number of answers.