/    Sign up×
Community /Pin to ProfileBookmark

adding a third color scheme. syntax in question.

My site will change color schemes when a user presses the button in the top left. I want to add a third theme though. I can’t figure it out though.

My html as relevent

[CODE] <!–EXTERNAL FILES–>
<link rel=”stylesheet” type=”text/css” href=”main.css” />
<!–[if IE]><link rel=”stylesheet” type=”text/css” href=”mainIE.css” /><![endif]–>
<link id=”altstyle” rel=”stylesheet” type=”text/css” href=”main.css” />
<script type=”text/javascript” src=”main.js”></script>
<!–STOP EXTERNAL FILES–>

<title>Votillity.com</title>

<!–CSS INTERNAL–>
<!–CSS INTERNAL–>

<!–JAVASCRIPT INTERNAL–>
<!–JAVASCRIPT INTERNAL–>

</head>

<body onload=”startTime()”>

<img class=”Zindexsty1″ style=”position: fixed; top: 0px; left: 0px;” src=”http://votillity.com/VotillityLogo1.png” alt=”VOTILLITY” />
<img class=”Zindexsty2″ style=”position: fixed; top: 0px; left: 0px;” src=”http://votillity.com/VotillityLogo2.png” alt=”VOTILLITY” />

<button id=”altstyact” class=”button” style=”position: fixed; top: 0px; left: 170px; width: 60px;”>Theme</button>[/CODE]

Javascript

[CODE]//ALTERNATE STYLES
function changeStyle()
{
var obj1=document.getElementById(‘altstyact’);
var obj2=document.getElementById(‘altstyle’)
test=true;
obj1.onclick=function()
{
test==true?
(obj2.href=’main2.css’,obj1.firstChild.nodeValue=’Classic’,test=false):
(obj2.href=’main.css’,obj1.firstChild.nodeValue=’Ice’,test=true)
}
}

if(window.addEventListener)
{
window.addEventListener(‘load’,changeStyle,false);
}
else
{
if(window.attachEvent)
{
window.attachEvent(‘onload’,changeStyle);
}
}
//STOP ALTERNATE STYLES[/CODE]

I don’t think you need the css’s. If, however, I’m wrong just let me know. Keep in mind that the javascript is external.

Here’s my site if you need a better look [URL=”http://votillity.com”]Votillity[/URL]

Thank you

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@957ChattertonauthorMay 16.2010 — also, in case you wanna know. I changed the image that you'll see by setting the z-index in both ex-css's. Check the source code to see it. If your using IE, it'll be mainIE.css and Main2.css, otherwise, main.css and main2.css
Copy linkTweet thisAlerts:
@957ChattertonauthorMay 16.2010 — oh, excuse me. You wouldn't see main2.cc there. If you wanna know then ask me and I'll private message the code to you
Copy linkTweet thisAlerts:
@957ChattertonauthorMay 17.2010 — bump again. I think the posts are just moving too fast
Copy linkTweet thisAlerts:
@criterion9May 17.2010 — This is the section where it changes your styles...
<i>
</i>test==true?
(obj2.href='main2.css',obj1.firstChild.nodeValue='Classic',test=false):
(obj2.href='main.css',obj1.firstChild.nodeValue='Ice',test=true)


This could also read as (in case you are confused by the shorthand):
<i>
</i>if(test==true){
obj2.href='main2.css';
obj1.firstChild.nodeValue='Classic';
test=false;
} else {
obj2.href='main.css';
obj1.firstChild.nodeValue='Ice';
test=true;
}


Do you know much about Arrays? That might be the way to go if you want it to cycle through style offerings.
Copy linkTweet thisAlerts:
@957ChattertonauthorMay 17.2010 — 4 or 5 replies to my own posts and I figure it out before you reply. lol. thanks though. Yes I used an array
Copy linkTweet thisAlerts:
@criterion9May 17.2010 — 4 or 5 replies to my own posts and I figure it out before you reply. lol. thanks though. Yes I used an array[/QUOTE]

Usually most people on here give a day or two before bumping their own post. Just saying...
Copy linkTweet thisAlerts:
@957ChattertonauthorMay 17.2010 — oh ok... sry bout that
Copy linkTweet thisAlerts:
@criterion9May 17.2010 — No biggie. I just didn't want you to get upset thinking all the other posts were getting more attention than yours. ?
×

Success!

Help @957Chatterton spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...