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:
- web site designing mobile
- what quickest , easiest ways ensure existing web pages display on mobile platforms?
- designing web interfaces mobile devices
there many more discussions on dealing - check them out using search.
Comments
Post a Comment