How does a mobile browser work?

0

In mobile browsers we usually have Mode Fast , aportuguesando will become ' Modo Rápido ', where, it leaves the sites lighter to be loaded, I know part of this is that the site itself considers access as Mobile access, but another part is the browser itself that changes, you can notice differences in the Facebook site when accessed by UCBrowser and Opera Mini. Well the question I have is exactly this, how does this work, how can a browser change the code of a page, and how to do this in code? Another question is how the sites indicate that the access is mobile or not, to see if it activates or not its mobile version, this can only be done with CSS, with media ?

    
asked by anonymous 24.08.2015 / 17:09

1 answer

3

As you said, CSS is a way to do responsive layout.

As long as it is programmed for this, the responsive layout automatically fits into the user's device (mobile, desktop, etc ...), that is, the responsive site changes its appearance and layout based on screen size at the site is displayed. If the user has a small screen, the elements must be readapted.

But it is not the case of Facebook, because the site is not responsive (media queries are used in responsive sites). What Facebook does is use javascript to check which device (mobile, desktop, etc ...) and redirect to the correct address for the device, which in the case would be " link ".

To check which device the user is using, I know this lib that makes it much easier: link

An example of how to check which device the user is using:

<script src="device.js"></script>
<script>
    var mobile  = device.mobile(),
        tablet  = device.tablet(),
        desktop = device.desktop();

    if(mobile) 
        alert("Acesso via mobile");
    else if(tablet) 
        alert("Acesso via tablet");
    else if(desktop) 
        alert("Acesso via desktop");
</script>

There are other utilities for this lib, such as whether the user is using android or ios, etc.

It's worth taking a look at the documentation.

    
24.08.2015 / 17:36