I am wanting to redirect to mobile version of website via javascript, based on screen size. I know how to implement this, however, im concerned that if i put this script in index.html, it will run every time the page is loaded, thus not allowing mobile users to access the desktop version because the script with recognize the screen size as mobile every time index (script) is loaded. Am i correct about this assumption? Work arounds, etc? Thanks
There are zero compelling reasons to do that. Several years ago, maybe. Even then a sane web page would adjust itself for a smaller screen automagically. It's what HTML does; it's called 'flow'. See the many posts from @deathshadow and read carefully his on progressive enhancement. gary
I might need to see a website before giving the right answer to you, but I believe making a responsive website is what you want to do instead of redirecting people elsewhere regarding to the screen size.
That you even have the notion in your head of a SEPARATE site for mobile, much less that scripttardery is the way to handle it? SOMEONE has been packing you so full of Manure that Biff Tannen could drive Marty's mom to the prom in you. Responsive layout exists for a reason. Semantic markup exists for a reason. Separation of presentation from content exists for a reason.... USE THEM!!! Particularly when your scripted width rubbish would be a giant middle finger at accessibility since JS sucks at pulling EM's preferring to work in px.