Closed Thread Icon

Topic awaiting preservation: Changing css on the fly (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8173" title="Pages that link to Topic awaiting preservation: Changing css on the fly (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Changing css on the fly <span class="small">(Page 1 of 1)</span>\

 
viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 05-19-2002 15:19

I - Is there a way so to, when I click a link in a page, I change on-the-fly the .css stylesheet file and, as a consequence, the page would reload automatically with a different look?

II - If this same page uses a .js script file inside its body, like this one:
<SCRIPT language=JavaScript src="array1.js" type=text/javascript></SCRIPT>,
when I click that same link mentioned in "I", is there a way to change also, on-the-fly, this script to a different one, like:
<SCRIPT language=JavaScript src="array2.js" type=text/javascript></SCRIPT>,

III - If the above is possible, is there a way to save the user configuration to a cookie so when he returns to that same page, the chosen .css and .js file is used?

Thanks.

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-20-2002 01:04

I - absolutely. See http://www.alistapart.com/stories/n4switch/

II - not really. I believe you'll have to include all the scripts right from the beginning.

III - the first link should tell you how to make cookies save the style sheet; you can use the cookies similarly to change the way the page should behave.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-20-2002 03:58

viol: Rather than answer this directly [edit: at least part I anyway] I thought it worth of an FAQ:
http://faq.ozoneasylum.com/FaqWiki/shownode.php?id=266

___________________
Emps

FAQs: Emperor

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 05-20-2002 15:03

Slime and Emperor, thank you both.
Based only on Slime's address, I have already worked out a way to do all I wanted, even changing the .js on-the-fly.
But I'll take a look at the FAQ. It's a well commented matter.
So much information, too little time to learn it all... :-)

jondoe
Obsessive-Compulsive (I) Inmate

From: UK
Insane since: May 2003

posted posted 05-20-2003 21:21

Try this


------ HEAD STUFF ---------------------------------------

<link rel="stylesheet" href="style_1.css">
<link rel="stylesheet" href="style_2.css">
<link rel="stylesheet" href="style_3.css">
<link rel="stylesheet" href="style_4.css">
<link rel="stylesheet" href="style_1.css">


<script language="JavaScript">
<!--
var doAlerts=false;
function changeSheets(whichSheet){
whichSheet=whichSheet-1;
if(document.styleSheets){
var c = document.styleSheets.length;
if (doAlerts) alert('Change to Style '+(whichSheet+1));
for(var i=0;i<c;i++){
if(i!=whichSheet){
document.styleSheets[i].disabled=true;
}else{
document.styleSheets[i].disabled=false;
}
}
}
}
//-->
</script>

------- BODY STUFF ---------------------------------------

<a href="JavaScript:changeSheets(1)">Style One</a>
<a href="JavaScript:changeSheets(2)">Style Two</a>
<a href="JavaScript:changeSheets(3)">Style Three</a>
<a href="JavaScript:changeSheets(4)">Style Four</a>

watchu talkin bout willis...

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 05-20-2003 21:27

This thread was one year and six hours old when you replied.

Emperor
Maniac (V) Mad Scientist with Finglongers

From: Cell 53, East Wing
Insane since: Jul 2001

posted posted 05-20-2003 22:39

..and as I said here:
www.ozoneasylum.com/Forum2/HTML/002157.html

we have covered this subject and come up with a range of solutions - including this one.

___________________
Emps

FAQs: Emperor

Suho1004
Maniac (V) Inmate

From: Seoul, Korea
Insane since: Apr 2002

posted posted 05-21-2003 01:14

Not to offend anyone's sensibilities, but this thread should have been archived long before it hit the one year mark.

viol
Maniac (V) Inmate

From: Charles River
Insane since: May 2002

posted posted 05-24-2003 10:18

wow, I didn't even remember that I had started this thread...

« BackwardsOnwards »

Show Forum Drop Down Menu