/    Sign up×
Community /Pin to ProfileBookmark

style sheet not being applied

I am linking to multiple style sheets through JavaScript, and it only is working on my home page, which is in the same file as everything else.

[B]My JS Stylesheets link[/B]

[code]
document.write(“<link rel=’stylesheet’ type=’text/css’ href=’style1.css’ title=’greenstyle’>”)
document.write(“<link rel=’alternate stylesheet’ type=’text/css’ href=’style2.css’ title=’redstyle’>”)
document.write(“<link rel=’alternate stylesheet’ type=’text/css’ href=’style3.css’ title=’tealstyle’>”)
document.write(“<link rel=’alternate stylesheet’ type=’text/css’ href=’style4.css’ title=’purpstyle’>”)
document.write(“<link rel=’alternate stylesheet’ type=’text/css’ href=’style5.css’ title=’blackstyle’>”)
document.write(“<link rel=’alternate stylesheet’ type=’text/css’ href=’style6.css’ title=’yellowstyle’>”)
document.write(“<link rel=’alternate stylesheet’ type=’text/css’ href=’style2-1.css’ title=’blackpinkstyle’>”)
document.write(“<link rel=’alternate stylesheet’ type=’text/css’ href=’style2-2.css’ title=’yellowgreenstyle’>”)
[/code]

[B]My link to the code above[/B]

[code]
<script type=”text/javascript” src=”/stylesheets.js”></script>
[/code]

[B]My Code to display the text links[/B]

[code]
document.write(“<ul>”)
document.write(“<li><h3>Select A Color Scheme</h3></li>”)
document.write(“<li><li><a class=”nav” href=”#” onclick=”setActiveStyleSheet(‘greenstyle’); return false;”>Green</a></li>”)
document.write(“<li><li><a class=”nav” href=”#” onclick=”setActiveStyleSheet(‘redstyle’); return false;”>Red</a></li>”)
document.write(“<li><li><a class=”nav” href=”#” onclick=”setActiveStyleSheet(‘tealstyle’); return false;”>Teal</a></li>”)
document.write(“<li><li><a class=”nav” href=”#” onclick=”setActiveStyleSheet(‘purpstyle’); return false;”>Purple</a></li>”)
document.write(“<li><li><a class=”nav” href=”#” onclick=”setActiveStyleSheet(‘blackstyle’); return false;”>Black</a></li>”)
document.write(“<li><h3>Multiple Colors</h3></li>”)
document.write(“<li><li><a class=”nav” href=”#” onclick=”setActiveStyleSheet(‘blackpinkstyle’); return false;”>Black/Pink</a></li>”)
document.write(“<li><li><a class=”nav” href=”#” onclick=”setActiveStyleSheet(‘yellowgreenstyle’); return false;”>Yellow/Green</a></li>”)
document.write(“</ul>”)
[/code]

[B]My problem:[/B]
I use the same script on my home page, only instead of src=”/stylesheets.js”, I use src=”stylesheets.js” I know that most of the code works, because the link is linking to the stylesheets, but it isn’t applying that style to that page.

[B]Try It:[/B]
[url]http://webtoolz.t35.com/[/url] is the site, and on the right hand side choose a color, then click on HTML on the left hand side, then body (also on left side). That page isn’t applying the CSS. Now once you have done that, choose another color while your still viewing the body page, then go back to the home page. It changed the color, but it isn’t still applying that new color to the body page. What is wrong?

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @The_Little_Guy 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.25,
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,
)...