简体   繁体   中英

Redirection with CSS and Javascript - handheld devices

I have been trying to redirect based on screen size generically on all desktop and hand held devices and I guess media queries is quite an answer to it because when i detected screen size with javascript screen.width then different browsers returned me different screen size which was quite irritating that why is this happening. Well I need to know two things will the following code detect the screen as javascript did or it'll detect generically 100% accurate screen size? and if so how can i trigger a rediretion javascript code if the following css rule being becomes true?

@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
  /* iPhone, Android rules here */
}

You could use a framework like jQuery or Mootools to avoid browser inconsistencies.

I may have written something that does what you want: http://jsfiddle.net/aUW4N/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM