queryloader2
queryloader2 copied to clipboard
Uncaught TypeError: Cannot read property 'replace' of null
In header, I add:
<script src="js/queryloader2.min.js" type="text/javascript">
(confirmed it exists or I wouldn't have this err)
In .ready I call the jquery:
$("body").queryLoader2();
(at the top)
The screen just goes black and doesn't come out after getting error 'cannot read property replace of null'
Seems like something is going wrong with detecting urls, will take a look later.
Encountered this problem when trying to embed Wistia popovers. Solved it by this:
findImageInElement: function(e) {
var t = this.determineUrlAndType(e);
if (!this.hasGradient(t.url)) {
t.url = this.stripUrl(t.url);
if (t.url = "undefined") return false;
for (var n = t.url.split(", "), i = 0; i < n.length; i++)
if (this.validUrl(n[i]) && this.urlIsNew(n[i])) {
var r = "";
(this.isIE() || this.isOpera()) && (r = "?rand=" + Math.random()), this.sources.push(n[i] + r)
}
}
},
And stripURL needed an if statement:
stripUrl: function(e) { if (e) return e = e.replace(/url\(\'/g, ""), e = e.replace(/url\(/g, ""), e = e.replace(/\'\)/g, ""), e = e.replace(/\)/g, ""), e = e.replace },
Not sure if this is the right solution, but it clears the errors and still loads normally for me.
Apologies in advance for formatting/providing my solution here, this is my first contribution on github.
@albanyacademy Thanks for contributing. I fear that your addition will not help as it's setting a variable instead of checking a condition. I will take your adjustments into consideration. If you'd like to contribute you can add a pull request with your adjusted code.