GiG
#1
How can I identify the browser I am using?
In Flash I was used to call a function with ExternalInterface, but the same function cause an error now
var browserAgent : String = ExternalInterface.call("function getBrowser(){return navigator.userAgent;}");
SyntaxError: expected expression, got '.'
Is there an alternative way or am I really missing a Syntax error?
You can try using methods from the Sys class (it comes comes standard with Haxe):
http://api.haxe.org/Sys.html
Edit:
The haxe.js package is probably a better option:
http://api.haxe.org/js/Browser.html
You can try this
public inline static function isFirefox():Bool
{
return Browser.navigator.userAgent.indexOf("Firefox") != -1;
}
GiG
#4
@dimumurray, @T1mL3arn
Browser.navigator.userAgent.indexOf("Firefox") != -1;
works, thank you guys!
I will give Sys a try, but for now I am ok with js.Browser.
So I don’t need ExternalInterface anymore… I wonder if I can avoid it in other situations too…