Author |
Topic  |
|
sr_erick
Senior Member
   
USA
1318 Posts |
Posted - 10 August 2004 : 22:51:29
|
Is there any way to store an image path or location in CSS? I'd like to create a javascript link to swap color themes and also swap out images by swapping out the CSS file that I use. Any tips on how I could go about this?? Thanks! |


Erick Snowmobile Fanatics
|
|
D3mon
Senior Member
   
United Kingdom
1685 Posts |
Posted - 11 August 2004 : 04:16:29
|
You could use ASP to dynamically write the CSS source path like:
<style type="css/text"> @import url("<%= strCurrentStyle %>") </style> |
 Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod "In war, the victorious strategist only seeks battle after the victory has been won" |
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
|
aspwiz
Junior Member
 
250 Posts |
Posted - 14 August 2004 : 03:59:50
|
Hi....
If you are running speedball 2, then this will be made much easier for you....
I have skinning available on my site (although, I have not skinned icons) |
 |
|
D3mon
Senior Member
   
United Kingdom
1685 Posts |
Posted - 14 August 2004 : 05:47:30
|
quote: Originally posted by redbrad0
What is the import url? Does it import a new CSS file, do you specify the CSS file in the import url?
strCurrentstyle might be "../styles/style1.css" for example |
 Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod "In war, the victorious strategist only seeks battle after the victory has been won" |
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 14 August 2004 : 15:48:42
|
So what is the difference in using importURL instread of ...
<link rel="stylesheet" type="text/css" href="<%= strCurrentStyle %>">
I think what erick would like to do is where they can click a icon and it changes all the images and everything without having to reload the page. |
Brad Oklahoma City Online Entertainment Guide Oklahoma Event Tickets |
 |
|
stuF
Average Member
  
United Kingdom
561 Posts |
Posted - 14 August 2004 : 15:57:09
|
Well, if the images are decorational only, and as such are set as bg elements, they can be defined in each different CSS file.
If however you want to drag different images into the site which are not suitable to be part of the BG, you'll have to do something different.
Couldnt you just use this for image locations:
<img src="<%= strCurrentStyle %>/logo.gif">
and then use the same technique for setting the active stylsheet. You'd just have to name the image folders the same as the name of the stylesheet.
|
http://36-degrees.co.uk |
 |
|
D3mon
Senior Member
   
United Kingdom
1685 Posts |
Posted - 14 August 2004 : 16:20:08
|
quote: Originally posted by redbrad0
So what is the difference in using importURL instread of ...
<link rel="stylesheet" type="text/css" href="<%= strCurrentStyle %>">
I think what erick would like to do is where they can click a icon and it changes all the images and everything without having to reload the page.
They are pretty much the same except older non-CSS capable browsers, wont try to use the css file if it is @imported |
 Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod "In war, the victorious strategist only seeks battle after the victory has been won" |
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
|
Steve D.
Average Member
  
USA
640 Posts |
Posted - 15 August 2004 : 00:12:43
|
quote: Originally posted by redbrad0
A site that does this is http://www.face2meet.co.uk which the color changer is in flash so not sure how they change all the images.
This is the javascript function they use to switch the themes...
function changeTheme(newTheme)
{
var pattern = /images\/themes\/\d{1,1}/ig;
document.body.innerHTML = document.body.innerHTML.replace(pattern,"images/themes/"+newTheme);
document.getElementById("customStyle").href='images/themes/'+newTheme+'/style.css';
createCookie("theme", newTheme,365);
}
|
Swing Dancing Video Clips - It's All Swing! Forum |
 |
|
redbrad0
Advanced Member
    
USA
3725 Posts |
Posted - 15 August 2004 : 02:53:11
|
So it looks like the below html will replace all images in the html with the location specified. Pretty nice Thanks Steve
document.body.innerHTML = document.body.innerHTML.replace(pattern,"images/themes/"+newTheme);
|
Brad Oklahoma City Online Entertainment Guide Oklahoma Event Tickets |
 |
|
Steve D.
Average Member
  
USA
640 Posts |
|
|
Topic  |
|