Search code examples
javascriptfilesaver.js

Way to use JavaScript to check browsers such like window, safari and chrome


I have a problem about using the following code to check browser

view =(
            typeof self !== "undefined" && self ||
            typeof window !== "undefined" && window ||
            this.content
        ); 
is_safari = /constructor/i.test(view.HTMLElement) || view.safari,
is_chrome_ios = /CriOS\/[\d]+/.test(navigator.userAgent),

The upper code snippet is from FileSaver.js, and the problem is what is the meaning of /constructor/i.test, it seems the javascipt api not include this function. Is there anyone know about that, thanks a lot.


Solution

  • It is standard JavaScript.