I am using IntersectionObserver and have a polyfill that should load if the browser isn't compatible. Unfortunately, things aren't working in IE11. In console, I can see an error that IntersectionObserver is undefined. I'd expect this if I wasn't loading the polyfill, but I should be! I checked the network tab, and it doesn't seem like IE ever downloaded the polyfill script. Any ideas why? Here's my code that should check whether the browser supports IntersectionObserver and loads the polyfill if it doesn't
<script type="text/javascript">
if (!('IntersectionObserver' in window)) {
var script = document.createElement("script");
script.src = "https://raw.githubusercontent.com/w3c/IntersectionObserver/master/polyfill/intersection-observer.js";
document.getElementsByTagName('head')[0].appendChild(script);
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.