queryloader2 icon indicating copy to clipboard operation
queryloader2 copied to clipboard

Uncaught TypeError: Cannot read property 'replace' of null

Open dylanh724 opened this issue 8 years ago • 3 comments

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'

image

dylanh724 avatar Apr 16 '16 05:04 dylanh724

Seems like something is going wrong with detecting urls, will take a look later.

Gaya avatar Apr 18 '16 09:04 Gaya

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 avatar Jun 07 '16 13:06 albanyacademy

@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.

Gaya avatar Jun 08 '16 14:06 Gaya