Just for details, here's what I tried to do,
When I started, the first thing I tried of course, was to just write tag with the css file in the header.
- Code: Select all
//Screen width
screenWidth = screen.width;
//Root string values
rootString = "css/web/verRes/";
defaultRootString = "css/web/";
//Select which screen resolution css files to utilize
if( (screenWidth >= 1030) && (screenWidth < 1060) ) //1050
{
fileName = rootString + "1050" + "/default.css\" />";
}
else if ( (screenWidth >= 960) && (screenWidth < 1030) ) //1024
{
fileName = rootString + "1024" + "/default.css\" />";
}
else if ( (screenWidth >= 850) && (screenWidth < 960) ) //900
{
fileName = rootString + "900" + "/default.css\" />";
}
else if ( (screenWidth >= 785) && (screenWidth < 850) ) //800
{
fileName = rootString + "800" + "/default.css\" />";
}
else if ( (screenWidth >= 744) && (screenWidth < 785) ) //768
{
fileName = rootString + "768" + "/default.css\" />";
}
else if ( (screenWidth >= 650) && (screenWidth < 744) ) //720
{
fileName = rootString + "720" + "/default.css\" />";
}
else if (screenWidth < 650) //600
{
fileName = rootString + "600" + "/default.css\" />";
}
else //Default value (large wide screen)
{
fileName = defaultRootString + "/default.css\" />";
}
document.writeln("<link rel=\"stylesheet\" media=\"screen\" type=\"text/css\" href=\"" + fileName);
The problem with that was that it loaded the css for everything else, but ignored all the locations of my background images. Why background images? I don't know.That stated, I thought I might get better luck using a more 'traditional' approach that I found on the net:
- Code: Select all
//Screen width
screenWidth = screen.width;
//Root string values
rootString = "css/web/verRes/";
defaultRootString = "css/web/";
//Select which screen resolution css files to utilize
if( (screenWidth >= 1030) && (screenWidth < 1060) ) //1050
{
fileName = rootString + "1050" + "/default.css";
}
else if ( (screenWidth >= 960) && (screenWidth < 1030) ) //1024
{
fileName = rootString + "1024" + "/default.css";
}
else if ( (screenWidth >= 850) && (screenWidth < 960) ) //900
{
fileName = rootString + "900" + "/default.css";
}
else if ( (screenWidth >= 785) && (screenWidth < 850) ) //800
{
fileName = rootString + "800" + "/default.css";
}
else if ( (screenWidth >= 744) && (screenWidth < 785) ) //768
{
fileName = rootString + "768" + "/default.css";
}
else if ( (screenWidth >= 650) && (screenWidth < 744) ) //720
{
fileName = rootString + "720" + "/default.css";
}
else if (screenWidth < 650) //600
{
fileName = rootString + "600" + "/default.css";
}
else //Default value (large wide screen)
{
fileName = defaultRootString + "/default.css";
}
var fileref = document.createElement("link");
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", fileName);
var headID = document.getElementsByTagName("head")[0];
headID.appendChild(fileref);
Unfortunately, this does the same exact thing. Proper formatting, but the images don't show up in the backgrounds and variable images sizes (which I painstakingly re-sized and formatted in PSP 7) are the main reason for resizing these things (everything else I could do with ems and %s).
So - has anyone ever run into this one before in designing dynamic CSS files.. and if so, how did you figure out how to get your background images back?
Thank you,
Dante