所以jQuery 3.0今天发布了,由于某种原因,以下代码不再适用于我的网站:
$(window).load(function() {});
任何人都可以建议我如何解决这个问题或者当/ every /加载时激活的替代方案?
解决方法
从
breaking-change-load-unload-and-error-removed开始阅读:
Breaking change: .load(),.unload(),and .error() removed
These methods are shortcuts for event operations,but had several API limitations. The event .load() method conflicted with the ajax .load() method. The .error() method could not be used with window.onerror because of the way the DOM method is defined. If you need to attach events by these names,use the .on() method,e.g. change $(“img”).load(fn) to $(img).on(“load”,fn).
因此,您需要更改:
$(window).load(function() {});
至:
$(window).on("load",function (e) {})