ashur112
01-12-2010, 10:52 AM
Hi.
I have a site that uses a big background. I found a script that looks up the users resolution and sets the bg based on that (mainly a question of setting a proper image for those 1024x768 users).The bg is fetched from a style sheet xxx.css.The script works by "onload".
--------------------------------------------------
...
<script type="text/javascript">
<!--
function switchCSS() {
if (window.screen.availWidth < 1280) {
var myLink = document.getElementsByTagName('link')[0];
if (myLink) myLink.setAttribute('href', 'xxx1024.css', 0);
}
}
//-->
</script>
</head>
<body onload="switchCSS();">
...
------------------------------------------------
How do I modify the script so that it looks up not only the resolution, but also the browser in question (IE) and gets the style sheet by gathered info (either xxx1024.css or xxx1024IE.css.)?
+I would like to make it a separate .js file, so that it doesn't clutter up the code.
I would be great if somebody could help.My own scripting skills are limited.:(
I have a site that uses a big background. I found a script that looks up the users resolution and sets the bg based on that (mainly a question of setting a proper image for those 1024x768 users).The bg is fetched from a style sheet xxx.css.The script works by "onload".
--------------------------------------------------
...
<script type="text/javascript">
<!--
function switchCSS() {
if (window.screen.availWidth < 1280) {
var myLink = document.getElementsByTagName('link')[0];
if (myLink) myLink.setAttribute('href', 'xxx1024.css', 0);
}
}
//-->
</script>
</head>
<body onload="switchCSS();">
...
------------------------------------------------
How do I modify the script so that it looks up not only the resolution, but also the browser in question (IE) and gets the style sheet by gathered info (either xxx1024.css or xxx1024IE.css.)?
+I would like to make it a separate .js file, so that it doesn't clutter up the code.
I would be great if somebody could help.My own scripting skills are limited.:(