How to check if character isn't supported by the user's browser in JavaScript?

泄露秘密 提交于 2020-02-14 03:14:26

问题


I'm building a site that uses a lot of emojis. Kind of like the one's you're used to seeing when texting, or on Instagram, Facebook, etc.

Examples: 😄 😘 😂

Of course, not all of the emojis are supported by all the browsers out there. When they aren't then they show up as a square with a question mark in the middle like so:

Is there anyway in JavaScript that you can tell if a character is supported by the browser, or if it'll show up like the question mark above?


回答1:


Browsers do not "support" displaying unicode characters, it's the font that is responsible. Of course, you can always directly include the font that you want to use to display the characters in the emoji section in Unicode with CSS.

Here is a free and open font that can display emojis.

In case you want to detect if a font exists, here is a tool for that.




回答2:


As others have noted.. It's not the browser but the font.. So specify a font that supports all your emojis



来源:https://stackoverflow.com/questions/34969876/how-to-check-if-character-isnt-supported-by-the-users-browser-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!