Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Show alert if style is not supported, without HTML

I would need something like this:

if {
  @supports not(display: grid) {
    window.alert("Please use a different browser.");
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

So if CSS grid is not supported by a browser, it should show a JavaScript alert. I know how it would work with just CSS, but I need a JavaScript or jQuery solution, without any HTML in the HTML section. How is it possible to do that?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You’re making this too complicated 😀

if (document.documentElement.style.grid === undefined) {
    alert("Please use a different browser.");
}

In modern browsers, grid is a property of the style of every element. If it’s undefined, then the browser doesn’t support it.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading