Is there a way to create, say createElement( "STYLE"), to create new classes
or style sheets from within JavaScript?
Thanks,
gsb 7 8206
gsb wrote: Is there a way to create, say createElement( "STYLE"), to create new classes or style sheets from within JavaScript?
Yes.
Thanks,
Welcome.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/
gsb wrote: Is there a way to create, say createElement( "STYLE"), to create new classes or style sheets from within JavaScript?
Thanks,
gsb
To create a new stylesheet:
var AccessibilityStyleSheet = document.createStyleSheet("Accessibility
style sheet", "projection,screen,tv");
For the general syntax, see: http://www.w3.org/TR/2000/REC-DOM-Le...eCSSStyleSheet
To populate that stylesheet:
AccessibilityStyleSheet.insertRule("p {color:green; font-size:120%}", 0);
AccessibilityStyleSheet.insertRule("div.someClassN ame
{background-color:blue}", 1);
For the general syntax, see: http://www.w3.org/TR/2000/REC-DOM-Le...eet-insertRule
The methods given are standard W3C DOM 2 CSS methods. You should expect
only recent browsers (like Mozilla 1.5+, Opera 7.5, Safari 1.2,
Konqueror 3.2) to support these W3C methods: untested and unverified.
MSIE uses different methods.
DU
DU wrote: gsb wrote:
Is there a way to create, say createElement( "STYLE"), to create new classes or style sheets from within JavaScript?
Thanks,
gsb To create a new stylesheet:
var AccessibilityStyleSheet = document.createStyleSheet("Accessibility style sheet", "projection,screen,tv");
It should have been written rather
var AccessibilityStyleSheet =
document.createCSSStyleSheet("Accessibility style sheet",
"projection,screen,tv");
As far as I know, currently no browser support createCSSStyleSheet.
document.implementation.createCSSStyleSheet() Not Implemented http://bugzilla.mozilla.org/show_bug.cgi?id=63850
For the general syntax, see: http://www.w3.org/TR/2000/REC-DOM-Le...eCSSStyleSheet To populate that stylesheet:
AccessibilityStyleSheet.insertRule("p {color:green; font-size:120%}", 0); AccessibilityStyleSheet.insertRule("div.someClassN ame {background-color:blue}", 1);
document.styleSheets[0].insertRule("p {color:green; font-size:120%}", 1);
document.styleSheets[0].insertRule("div.someClassName
{background-color:blue}", 1);
will work in Mozilla-based browsers.
DU
For the general syntax, see: http://www.w3.org/TR/2000/REC-DOM-Le...eet-insertRule
The methods given are standard W3C DOM 2 CSS methods. You should expect only recent browsers (like Mozilla 1.5+, Opera 7.5, Safari 1.2, Konqueror 3.2) to support these W3C methods: untested and unverified. MSIE uses different methods.
DU
DU wrote: DU wrote:
gsb wrote:
Is there a way to create, say createElement( "STYLE"), to create new classes or style sheets from within JavaScript?
To create a new stylesheet:
var AccessibilityStyleSheet = document.createStyleSheet("Accessibility style sheet", "projection,screen,tv");
It should have been written rather
var AccessibilityStyleSheet = document.createCSSStyleSheet("Accessibility style sheet", "projection,screen,tv");
No, it should be
document.implementation.createCSSStyleSheet(..., ...)
but that is not supported by Mozilla or other browsers and wouldn't help
as the DOM spec itself admits that there is no way to associate the
created stylesheet with a document.
--
Martin Honnen http://JavaScript.FAQTs.com/
Thanks all.
Looks like I can get it to work.
gsb
"gsb" <gs*@QWest.net> wrote in message
news:f5*****************@news.uswest.net... Is there a way to create, say createElement( "STYLE"), to create new
classes or style sheets from within JavaScript?
Thanks,
gsb
On Thu, 19 Feb 2004 09:17:11 -0800, gsb wrote: Thanks all. Looks like I can get it to work.
gsb
Hi,
I am curious... and late to thsi thread...
What was the scenario for generating style data dynamically?
Thx
DK This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: David Bradbury |
last post by:
I may be thinking about this the wrong way, but here goes:
In my style sheet I've specified that bullet points should use a
specific image rather than just be default bullet points. However, at...
|
by: Michael Bierman |
last post by:
Please forgive the simplicy of this question. I have the following code
which attempts to determine the color of some text and set other text
to match that color. It works fine in Firefox, but does...
|
by: charley |
last post by:
Hello,
The appearance of the page should be for the main image, lpmap.jpg, to
be on the bottom, (z-index: 1), with pictures, (image0.jpg -
image9.jpg), and accompaning notes to appear on top,...
|
by: Waffeloo |
last post by:
Hi,
I would like an event to trigger a change the style of all the elements that
belong to some CSS class.
I know it is possible to change the class of an element, for example with:
<script...
|
by: davidw |
last post by:
As I asked in last post, I want to put some logic in a object and all my
webcontrol instance will access that object, the object is responsed to
retrieve data from database if the data has not been...
|
by: JezB |
last post by:
Is it possible to programatically examine and modify a page's Styles
(including Cascading Style Sheets) within the code-behind-module (eg. c#) ?
My guess is that since these are HTML elements the...
|
by: MarkoH |
last post by:
Wsdl.exe /server creates abstract class derived from WebService. Is there a
way to create this class at runtime based on some WSDL file given at runtime
? What would be even better - creating...
|
by: sirjohnofthewest |
last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man.
Hi guys, I frequently visit this site to get answers to my...
|
by: Nathan Sokalski |
last post by:
I have css that would normally be placed in style tags in the header of the
Master page that I want to add programmatically for a specific Web Content
Form (the *.aspx page). How do I do this for a...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |