Tag Archives: Javascritp

How to redirect for mobile devices

Javascript   <script type="text/javascript"> <!– if (screen.width <= 699) { document.location = "http://fullpath-to-your-mobile-page/mobile.html"; } //–> </script>   iPhones/iPods   <script language=javascript> <!– if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {    location.replace("http://fullpath-to-your-mobile-page/iphone.html"); } –> </script>  
Posted in JavaScript | Also tagged , , | Leave a comment

How to change CSS style depending on day of the week

First, create one css file for each day of the week, and name them like this: sunday.css, monday.css, tuesday.css etc. JavaScript   <script type="text/javascript"> <!– dayNames = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; dayNumber = new Date().getDay(); document.writeln(‘<link rel="stylesheet" type="text/css" href="’ + dayNames[dayNumber] + ‘.css">’); //–> </script>   <noscript> <link rel="stylesheet" type="text/css" href="default.css"> </noscript> [...]
Posted in JavaScript | Also tagged , , | Leave a comment