The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse',

Viewed 24

I have this code to check if a url is from youtube or not, then use try catch to check if it valid in iframe - but the try catch didnt work I got this error:

The service worker navigation preload request was cancelled before 'preloadResponse' settled. If you intend to use 'preloadResponse', use waitUntil() or respondWith() to wait for the promise to settle.

any solution ? thanks

const s = document.getElementsByClassName("responsive-iframe")[0].src;
 async function youtubeshow(id)
{
  


if((document.getElementsByClassName("addlinkss")[0].value.slice(0,17)=='https://youtu.be/' && document.getElementsByClassName("addlinkss")[0].value.length==28)  )
{
  
    try {
 document.getElementsByClassName("responsive-iframe")[0].src='https://www.youtube.com/embed/'+document.getElementsByClassName("addlinkss")[0].value.slice(17);
}
catch(e){
  alert("ez");
$('#responsive-iframe').attr('src', s);
}
}else{
    document.getElementsByClassName("responsive-iframe")[0].src=s;
    console.log("no"+document.getElementsByClassName("addlinkss")[0].value.length);
 document.getElementsByClassName("addlinkss")[0].focus();
}

 
  
}

0 Answers
Related