user13396528
user13396528

Reputation: 21

Browser support for a specific code of JavaScript

I was trying to detect if a browser supports innerHeight...

Is there any tag to check browser support for a specific code of JavaScript like that of @supports in CSS?

Upvotes: 0

Views: 40

Answers (2)

Cristian Richard
Cristian Richard

Reputation: 26

You can use what you're trying to use in an "if" statement

if(window.innerHeight) 
    console.log("window.innerHeight supported"); 
else 
    console.log("window.innerHeight not supported");
div=document.getElementsByTagName("div")[0];
if(div.innerHeight) 
    console.log("div.innerHeight supported"); 
else 
    console.log("div.innerHeight not supported");

Upvotes: 0

Joel Hager
Joel Hager

Reputation: 3440

InnerHeight has a 95.22% all-time browser support rating. Pretty sure you're safe using it. :)

https://caniuse.com/#feat=mdn-api_window_innerheight

Upvotes: 2

Related Questions