Jump to content

Changing styles on the fly


virtual_odin

Recommended Posts

OK, I am creating a control panel pop-up to allow administrators to change certain style settings on a page.  The settings themselves are stored in a MySQL table and once the new set-up is acceptable, can be saved back to MySQL so that every future impression of the page is in the new style.  So far so good. 

 

I have also successfully changed the master document by writing the new style back to the main page using the id/name of a tag, but this requires every instance to have a unique id/name because otherwise if the names are the same, only the first instance of the object is changed.  In fact the document has multiple instances of the same style/class.  So I want to set up the styles in <head></head> and call them each time they are needed with a class= tag.

 

Bottom line: can Javascript change these style settings in head and have the document change as a result?  If so how?

 

My workaround if this is not possible is to save the changes as they are made and re-load the page each time, but I would have to do some fancy footwork to allow regression and it all sounds heavy, when just re-writing the styles would be really neat.

 

As always, I would appreciate suggestions.

 

The test site here is http://example.club-host.com (please excuse the gross colours - they are just there while I sort out table layout, etc).  Click on "Admin" to see the control panel.

Link to comment
Share on other sites

The template you are using looks pretty simple and can be controled using javascript easily without overwriting the style.

 

Since you have a few elements (Header, navigation, side navigation, body, right side, footer) you can make the javascript to change these sections attributes. If you have a lot of links inside (like the navigation), just use the getElementsByTagName and loop through the objects the overwrite their style.

 

You still can overwrite the style tag (I never done that) or access it's childer (classes, definitions, etc)

 

You can view this for more details on the styleSheet

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/objects/obj_stylesheet.asp

 

For colors, you can use the NoGray color picker

 

Good luck

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.