Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Styles Dynamically

Status
Not open for further replies.

CliveC

Programmer
Nov 21, 2001
1,222
US
I have a page linked to a style sheet and on invoking the page I would like to be able to allow the user to choose between "regular" and "sight-impaired" versions. Is there a way to either specify which style sheet to use, or, to dynamically change the contents of the linked style sheet.

Any help would be much appreciated.
 
CliveC, this is just a thought, bu why not have a prompt pop up asking the user how the page should be displayed and depending on what the user selects, have that page load (either the user selects the normal or thE css version)...
Am I explaining it right?? I have not failed; I merely found 100,000 different ways of not succeding...
 
If it was a small page that would be fine but it is quite a long book and it seems redundant to store it again with the only change being the name of the style-sheet.
 
I work with an intranet where we develop for IE so I can tell you how to do it for IE only.

There is a collection in the DoM called styleSheets. If your page has more than one style sheet then yoo can iterate ove them with the length property.

Assuming that you wanted to change the first style sheet you can simply do

document.styleSheets[0].href='
and pow! your web page has changed.
 
Have you thought about using the Query String ? You could give the reader the option for visually impaired display. Then link to the page and pass the variable eg...
<a href=&quot;page1.htm&disply=impaired&quot; ( or 'normal' )....

on page1 ( & all pages ) you could check the value for 'display'. You could then load the correct stylesheet.

By passing the value for 'display' to each new page it will continue to display correctly.

Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top