How to make element appear only for Mozilla Firefox users

Asked

Viewed 29 times

3

I have a site that is not half misaligned on Mozilla Firefox, I tested in some browsers, including the Internet Explorer, who by the way displayed the page perfectly.

Only the Mozilla Firefox You have that problem. At the moment I’m kind of running out of time to try to resolve this, so I want when the person accesses the site to be displayed a warning to them indicating the use of another browser.

Code example:

<div id="mozilla"> Percebemos que você está utilizando o navegador Mozilla.
     Para uma melhor interação com nosso site, indicamos que utilize
    outro navegador, como Google Chrome, Internet Explorer, etc.
<span id="x">Fechar</span> </div>

It is possible to make this warning above appear only if the person accesses the page using the browser Mozilla Firefox?

Another little thing, how to give style="display:none" à <div>, if the person clicks close?

  • Can you put here an example of what doesn’t work? can be useful to others and we can help solve...

  • I didn’t, rsrs, it’s just a question I want to implicate on my site :D

1 answer

3


var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') != -1;

That line looks for the word firefox in the browser’s digital signature, useragent string.

If isFirefox for true is a Firefox browser.

  • How cool !!!! : D :D :D

  • Sergio, I’m sorry, I’m a little layman, can you show me with the example I quoted ? : P

  • 1

    @AlexandreLopes https://jsfiddle.net/z91rh3L3/

  • 1

    Genial !!! My congratulations Sergio, you have a knowledge Itanto. Thank you so much for helping beginners like this guy here :P

Browser other questions tagged

You are not signed in. Login or sign up in order to post.