Including a css sheet is easy and works well with the code below. However this must not be a good way to include a javascript file because I get an error when I view it in the iPad. Something about an unclosed tag. I assume I’m getting nested tags by doing it this way. What should I be doing instead?
<script type="text/javascript">
//Sniff out iPads
if (navigator.userAgent.indexOf('iPad') != -1) {
document.write('<link rel="stylesheet" type="text/css" href="/styles/browser/ipad.css" media="screen, print" />');
document.write('<script src="/scripts/ipad.js" type="text/javascript" />');
}
<script>
For the
ipad.jsyou can detect inside the javascript. For the CSS just use conditional comments (if you’re supporting older IE versions) and themediaattribute to exclude loading it in IE and other browers: