/    Sign up×
Community /Pin to ProfileBookmark

how can i chang css withhout refresh

Hi all

plz wanna to know a thing

if i can chang the external link to style sheet without refresh my bage

such change the background color without refresh page

-=-=-=-=-
mean that

change this code in the page

<link href=”http://domain.com/example.css” rel=”stylesheet” type=”text/css”>

to

<link href=”http://domain.com/example2.css” rel=”stylesheet” type=”text/css”>
and
<link href=”http://domain.com/example3.css” rel=”stylesheet” type=”text/css”>
and
<link href=”http://domain.com/example4.css” rel=”stylesheet” type=”text/css”>

with abutton or inbut or any thing except refresh the page

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@ZnupiOct 08.2006 — That's fairly easy... All you have to do is add an id to your link tag, and then change its href... like this:
[code=php]
<link href="example.css" rel="stylesheet" type="text/css" id="myStyles">
----
<script type="text/javascript">
function changeStyles(newHref) {
document.getElementById('myStyles').href = newHref;
}
</script>
----
<a href="javascript:changeStyles('example2.css')">Change styles</a>
or
<button onClick="changeStyles('example2.css')">Change styles</button>
[/code]

That should do it, that's the way I did it... If you can't add an id to your <link> tag, let me know and I'll make a more elaborate script (which is not too hard as well, but it's useless if you can add an id...)
Copy linkTweet thisAlerts:
@kareem289authorOct 08.2006 — It's so wonderful :eek:

that's what i need ?

thanks alot :rolleyes: .
Copy linkTweet thisAlerts:
@robmarstonJul 01.2009 — Doing that still causes the page to refresh in FF3 OS X.
×

Success!

Help @kareem289 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.29,
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,
)...