/    Sign up×
Community /Pin to ProfileBookmark

Stlye switcher, noting doing.

In my head element I have:

[code]
<link rel=”stylesheet” type=”text/css” href=”cba.css” id=”mainstlye” />
<script type=”text/javascript”>
function SymError() {return true;}
window.onerror = SymError;
function style(name)
{document.getElementById(‘mainstyle’).href = name+”.css”;}
</script>[/code]

and in my body element I have:

[code]<script type=”text/javascript”>
document.write(“<img src=’graphics/style_cba.gif’ onclick=’style(cba);’/><img src=’graphics/style_cool.gif’ onclick=’style(cool);’/>”);
</script>[/code]

Both the images appear fine, but when I click on them nothing happens, according to Firefox’s js console there are no errors.
Clearly I am missing something incredibly obvious, any idea what?

[url=http://cherryblossomart.ntwebsite.net]The site in question[/url]

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@PittimannFeb 18.2005 — Hi!&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
&lt;title&gt;Example&lt;/title&gt;
&lt;link rel="stylesheet" type="text/css" href="cba.css" id="mainstyle"&gt;
&lt;script type="text/javascript"&gt;
function SymError() {return true;}
window.onerror = SymError;
function styleF(name)
{document.getElementById('mainstyle').href = name+".css";}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type="text/javascript"&gt;
document.write('&lt;img src="graphics/style_cba.gif" onclick="styleF(\'cba\');"&gt;&lt;img src="graphics/style_cool.gif" onclick="styleF(\'cool\');"&gt;');
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
Cheers - Pit
Copy linkTweet thisAlerts:
@the_treeauthorFeb 18.2005 — Thanks but still nothings happening.
Copy linkTweet thisAlerts:
@PittimannFeb 18.2005 — Hi!

Try this: http://www.pit-r.de/scripts/styleSwitcher.htm

Works for me on IE6, NS7.02, FF and Opera 7.54

Cheers - Pit
Copy linkTweet thisAlerts:
@the_treeauthorFeb 18.2005 — O.k. I've copied that, exactly, onto [url=http://cherryblossomart.ntwebsite.net]the site[/url] but it still seems to be doing nothing.

Might this be because I'm using an xhtml doctype?
×

Success!

Help @the_tree 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.18,
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,
)...