Html5 open from pc or smarthphone

There is a way to know if your html5 project is open from an pc or a smarthphone? so we can make some kind of responsive webpage with openfl, or maybe call another especific class for each one

Hi Vicente_Fleitas.

There’s a JavaScript library claiming to detect a mobile device.
I don’t know if it’s useful in your case though! Just check it out: Link

Thanks! will try that, but openfl just work with haxe libraries i think

Yeah it might not suite your needs. I wanted to do something different the time
I found isMobile - the user should get two completely different versions of the application
based on the target device so there was no need to do the distinction within the haxe code.
I found an old thread which might help: Link
Well as I said it’s a bit old - maybe it won’t work anymore. :wink:

1 Like

OpenFL HTML5 is JavaScript, so of course it works with JavaScript :slight_smile:

Download “isMobile.min.js” to your project somewhere, and add it to your dependencies, such as:

<dependency path="path/to/isMobile.min.js" />

When you build your project, OpenFL will copy the file into the right location and link it from the generated HTML page. Now, with an external script included, we just need to use some untyped JavaScript code, such as:

var iPhone = untyped __js__("");

If someone wants to make this even nicer, this could be done with externs

extern class IsMobile {
    public var apple:AppleDevices;

typedef AppleDevices = {
    var phone:Bool;

Something like that could make this work without using any untyped code, which long-term is a nicer approach :wink:

That would allow use like

var iPhone =;
1 Like