473,397 Members | 2,099 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Changing CSS Styles in a main page

Hi, everyone!

I hope you guys can help me. I´m working on a website which deals with 4 different css styles. Once in the Homepage, the user can choose one link out of four to enter the site. Depending on the link he chooses, all the following pages will follow a different style. So, my question is: how can I make this decision taken in Home to be understood by all the other pages? The css style they´ll load depends on this previous choice.. I´ve searched the web after sollutions and I think Javascript can help me, but I know just a little about it. Can you help me? I know what I have to do, theorically, but I don´t know how to translate it into a code..

Thank you all,

Rafael
Oct 24 '08 #1
6 1426
Nepomuk
3,112 Expert 2GB
...I´ve searched the web after sollutions and I think Javascript can help me, but I know just a little about it. Can you help me?
Hi Rafaell!
Obviously, you have made the same mistake as many newbies do - you confused Java with JavaScript. They aren't the same, actually not even very closely related (although the syntax has quite a few similarities). I'm moving this to the JavaScript Forum, where it belongs. Good luck with your task!

Greetings,
Nepomuk (Moderator)
Oct 24 '08 #2
I know what I have to do, theorically
what....theoretically.... would you like to do?
Do you want to change css classes you have already defined?
Are you looking to define and handle all classes in javascript?
There are ways to do either of these, and more....do you have a page started?

the basics are:

Expand|Select|Wrap|Line Numbers
  1.      myHTMLElement.style.border="2px red groove"
  2.      myHTMLElement.style.zIndex=3
  3.  
  4. or
  5.  
  6.      myHTMLElement.className="myClassName"
  7.  
Oct 25 '08 #3
Hi Rafaell!
Obviously, you have made the same mistake as many newbies do - you confused Java with JavaScript. They aren't the same, actually not even very closely related (although the syntax has quite a few similarities). I'm moving this to the JavaScript Forum, where it belongs. Good luck with your task!

Greetings,
Nepomuk (Moderator)

Thank you! Hope I´ll be luckier now.
Oct 25 '08 #4
what....theoretically.... would you like to do?
Do you want to change css classes you have already defined?
Are you looking to define and handle all classes in javascript?
There are ways to do either of these, and more....do you have a page started?

the basics are:

Expand|Select|Wrap|Line Numbers
  1.      myHTMLElement.style.border="2px red groove"
  2.      myHTMLElement.style.zIndex=3
  3.  
  4. or
  5.  
  6.      myHTMLElement.className="myClassName"
  7.  

Hi, zaphod42!

Thanks for your reply. I have four .css files. In the main page, I want the user to choose among four ways of loading the other pages, each way will load a .css style. The user will chose this by clicking on a link. I don´t want to change the .css files itself. And I have only a few functions in javascript.

I still don´t have the main page coded, but every other page, by now, has this line in its code:
Expand|Select|Wrap|Line Numbers
  1. <link rel="stylesheet" type="text/css" href="FILE.css" />
The point, I guess, is that this line shouldn´t be in each page, at least not with this "FILE.css" defined, because the instruction of loading a specific CSS file has to be given by the link in which I clicked in the main page. Is there a way to make LINK_1 on the main page load the FILE_1.css in every other page, and LINK_2 load FILE_2.css and so on?
Oct 25 '08 #5
if you want to do it client side you could add a hash to the url to tell the pages which link was clicked...but you would also have to add that hash to and local links on your page to ensure the style loads properly
Oct 25 '08 #6
acoder
16,027 Expert Mod 8TB
It would make sense to do this via the server-side, so that the CSS file is loaded during page load. You can use JavaScript if you want. Use cookies to store the preference. You may find this article useful.
Oct 25 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: DJ WIce | last post by:
Hi, I have this situation: I have a main page with content and an IFRAME on it. The IFRAME has it's own style sheet and the body of that uses a class: <body class="IFbody"> How can I...
0
by: Quinton | last post by:
I'm running a website that uses CSS to format the text and a CGI program Coranto that icludes news updates via SSI. My problem is that some parts of the CSS don't seem to take effect on the...
12
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a...
4
by: Sam Carleton | last post by:
How do I change the CSS colors via JavaScript DOM? Let me explain... I am working on a Windows application (in C#) that displays some HTML. In one place the HTML is a status window. What happens...
4
by: Sam Carleton | last post by:
How do I change the CSS colors via JavaScript DOM? Let me explain... I am working on a Windows application (in C#) that displays some HTML. In one place the HTML is a status window. What happens...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.