I have an example where I need to check if Safari V 5.1 supports FileReader
function. I tried with:
if (typeof FileReader !== "object") {
alert("NA");
}
However now even in my other browsers which I know for a fact they support FileReader
I get the alert displayed! So I imagine I must be doing something wrong.
check if the function is defined or not:
have you tried the following?
if(typeof(window.FileReader)!="undefined"){
//Your code if supported
}else{
//your code if not supported
}
From MDN
The window property of a Window object points to the window object itself.
JS IN operator can be used.
if('FileReader' in window)
console.log('FileReader found');
else
console.log('FileReader not found');
OR using given code sample.
if (!'FileReader' in window) {
alert("NA"); // alert will show if 'FileReader' does not exists in 'window'
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With