Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch to a mobile view with plain HTML

Tags:

html

mobile

I need to switch to a mobile view of a website using plain HTML or javascript... er, anything that doesn't require serverside scripting. Our website is being semi-temporarily hosted via Dropbox. ( http://teammetalcow.com redirects to a HTML file in the public folder.) I need a way so that we can detect the user's type of device then display a mobile or desktop version, appropriately. Having a simple way to tack on a mobile site would be prefferred. Is this even possible? Tons of thanks if you can help.

like image 278
Thaddeus Hughes Avatar asked Dec 20 '25 02:12

Thaddeus Hughes


1 Answers

You can try some library like breakpoint : https://github.com/martinmartinmartin/breakpoint/ or study this javascript : http://www.sitepoint.com/javascript-media-queries/

you just need to detect device with javascript, then redirect.

// in case of a viewport
if (document.documentElement.clientWidth < 900) {
// scripts --> redirect
    window.location = "http://www.disney.com"
}

// in case of a screen
if (screen.width < 900) {
// scripts --> redirect
    window.location = "http://www.disney.com"
}

Carry on

like image 66
Milche Patern Avatar answered Dec 22 '25 19:12

Milche Patern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!