JavaScript Newb - Screen Width and CSS, ARGH! -


i'm trying write bit in javascript mobile website. i've searched on google , found help, i'm having kind of problem implementing it.

in html header (note, no css file specified here):

<script type="text/javascript" src="scrnsz.js"></script> 

javascript:

if (screen.width > 200) { link = document.getelementsbytagname("link")[0]; link.href = "style.css"; }  if (screen.width <= 200) { link = document.getelementsbytagname("link")[0]; link.href = "smstyle.css"; } 

can pros help? :) thank you.

to make work, you'd need lone <link rel='stylesheet'> instruction in head. script search first 1 finds, , replace href accordingly.

however, there more ways , options prepare site mobile browsers. check out these questions:

there many more discussions on dealing - check them out using search.


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -