UserAgent error


#1

I’m getting this error in the console when my mod nkknkn is embedded on a page:

Uncaught TypeError: Cannot read property 'userAgent' of undefined at anymod.com.toolkit.js:1

for this line of code:

return /msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase())

Is that an internal error or am I doing something wrong?


#2

Hmm I don’t believe we’ve seen that one before. What browser are you using?


#3

Latest Chrome. Not seen it before myself either.


#4

We are looking into this; have not been able to replicate it so far. What OS are you on, and is there anything else you think might be relevant (browser extensions, etc)?


#5

Nothing has changed in my browser or on my site in the last few days.

Here’s a dev link for the site: https://bloomtest.carrd.co

If you don’t see the error in the console it must be something in my browser.


#6

Can you add me to the project? (tyler@anymod.com) The toolkit (pencil editor) doesn’t load for me so I’m not getting the same experience.


#7

Can I invite if I’m on the free plan?


#8

I thought I bumped it so you could – is it saying you can’t?


#9

Yeah - telling me to upgrade. I’ll try signing out and back in.


#10

Signing out/in didn’t make any difference.


#11

Can you try again now. No log out/in needed (page refresh maybe needed though)


#12

Yep- that worked :+1: :+1:


#13

OK great, I’m seeing the error now. We’ll have a look and let you know!


#14

My guess is the line

self = this

in your mod is overwriting the window object at the global level. I think changing it to

let self = this

will fix the issue

Edit

Alternatively, you can use the double arrow for ES6 here:

klasses.forEach(function(klass) {
klasses.forEach(klass => {

And you will be able to use this inside the function block without needing a self variable


#15

Changed it to _this and the error went away :+1:


#16

Oooh! arrow function, even better! No need for local assignments :tada:


#17

Yes it’s very post-modern => :arrow_right: