This is a discussion on "change style sheets" within the Web Page Design section. This forum, and the thread "change style sheets are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
change style sheets
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
change style sheets
hi ive been given this javascript code to be put into an html document which enables me to change between external stylesheets. i would also like to change between the original html page too. If possible an internal javascript code.
Heres the Xhtml code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <link type="text/css" rel="stylesheet" href="Q2sheet1.css"/> <title>Question 2</title> <meta http-equiv="content-type" content="text/html; charset=utf-8 code"/> </head> <body> <h1>styles.html</h1> <h2>Harry Potter...</h2> <big>H</big>e-Who-Must-Not-Be-Named has been named. Ralph Fiennes, who played memorable evil guys in "Red Dragon" and "Schindler's List," has signed on to portray the wicked warlock Voldemort in the next "Harry Potter" movie, Warner Bros. announced Wednesday. Voldemort is so bad that the magical characters in author J.K. Rowling's stories do their best not to speak his name aloud. XP</p> </body> </html> And heres the Javascript code ive been given to crack !: function changeStyleSheet(url) { //find <link> tag with attribute rel="stylesheet" var links = document.getElementsByTagName('link') ; for (var i=0; i<links.length; i++) { if (links[i].getAttribute('rel') == 'stylesheet') { var theLink = links[i] ; break; } } //If we found a stylesheet <link> then change it ! if (theLink) { //replace its href attribute with the new URL theLink.setAttribute('href', url) ; } } PLEASE IF ANYONE CAN HELP ILL APPRECIATE IT. |
|
|
|
|||
|
please explain your question further... you want the chosen CSS to persist accross pages?
|
|
|||
|
no, i just want the page to have three buttons using the javascript code given.. so that one page can switch between two stylesheets i have and one original html page. All from the main page.
thanks! |
|
|||
|
|
||||
|
i dont understand... so effectivly u want to switch between 3 different styles?
|
![]() |
| Tags |
| change, style, sheets |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Style sheets | Oak | Web Page Design | 4 | Mar 3rd, 2008 16:49 |
| switching between style sheets | cwjones | Web Page Design | 4 | Jul 4th, 2007 17:06 |
| Problems with external style sheets | ronb | Web Page Design | 7 | May 16th, 2007 19:18 |
| CSS Style Sheets | ronb | Starting Out | 3 | May 10th, 2007 13:02 |
| ***Help Needed accessing external Style Sheets*** | shawn2000 | Flash & Multimedia Forum | 1 | Nov 15th, 2006 22:32 |