Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Onload Change CSS based on Res

Status
Not open for further replies.

Ghost81st

Programmer
Nov 8, 2004
5
US
I have a php page and I am trying to get it to change css sheets based on window resolution so far I have this but it doesnt work:

Code:
<head>
<title>test Page</title>
<script type="text/javascript">
function RedirectCSS(){
    var h;
    switch(screen.width) {
        case '800':
            h = "index800.css";
            break;
        default:
            h = "index1280.css";
            break;
    }
    document.getElementsByTagName("link")[0].href = h;
}
</script>
</head>
<body onload="RedirectCSS();">

if you want to see the page itself:
Test Site
 
You need to have a <link rel="stylesheet" href="somewhere"> in the head if you want to change its href!

--Chessbot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top