Random Quote Machine - not compatible with some browsers?

Random Quote Machine - not compatible with some browsers?
0

#1

Hi guys,
I am desperately trying to figure out why my Random Quote Machine is working in some browsers, and isn’t working with others (quote isn’t loading).

Here are the browsers i tried so far:

  • Firefox: works
  • Edge: works
  • Chrome: doesn’t work
  • Mobile Safari: doesn’t work
  • Edge on mobile: doesn’t work

In the last few hours, I tried a lot to fix it, but apparently not everything yet… I suppose it has to something with the method I’m using to get the json-file - or is it a https-issue? I found another Quote Machine which uses the same quote source as mine, but I couldn’t find out why my approach (apart from being a bit different than his) hass cross-browser issues…

If you could give it a look and find out anything - man, I would be so happy.


#2

#3

Thanks for the link - I can see now why it shouldn’t work in IE and Safari - but from the information on that site it should work in the current version of Chrome; also, the Object.values() method worked in Chrome before during the Convert JSON Data to HTML lesson where it is also used!
Confusing…


#4

You need to enable it to use in Chrome:

Basic support 51.0 [1]
[1] Behind a flag.

Input chrome://flags in your Chrome browser and see all the functions you can enable/disable. One of them is support for Object.values(). But you shouldn’t ask users to enable experimental features in their browsers.

Regarding FCC’s lesson, they are probably using transpiler like Babel to convert it to supported format. Paste that code from lesson here (in the left window) and see how it gets transformed to universally supported code

EDIT:

In that lesson they are not using Object.values(), but Object.keys() and that is supported in Chrome.


#5

Aaaaahhh, great! Thank you so much :+1:! Apparently, I confused Object.values() with Object.keys()…

Instead of
currentQuote = Object.keys(json)[0]; //experimental, only Firefox
I rewrote it to
var txt = json["quoteText"]; currentQuote = txt;
and it works.