Is there a way to create, say createElement( "STYLE"), to create new classes
or style sheets from within JavaScript?
Thanks,
gsb 7 8233
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.javas cript 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 AccessibilitySt yleSheet = document.create StyleSheet("Acc essibility
style sheet", "projection,scr een,tv");
For the general syntax, see: http://www.w3.org/TR/2000/REC-DOM-Le...eCSSStyleSheet
To populate that stylesheet:
AccessibilitySt yleSheet.insert Rule("p {color:green; font-size:120%}", 0);
AccessibilitySt yleSheet.insert Rule("div.someC lassName
{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 AccessibilitySt yleSheet = document.create StyleSheet("Acc essibility style sheet", "projection,scr een,tv");
It should have been written rather
var AccessibilitySt yleSheet =
document.create CSSStyleSheet(" Accessibility style sheet",
"projection,scr een,tv");
As far as I know, currently no browser support createCSSStyleS heet.
document.implem entation.create CSSStyleSheet() 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:
AccessibilitySt yleSheet.insert Rule("p {color:green; font-size:120%}", 0); AccessibilitySt yleSheet.insert Rule("div.someC lassName {background-color:blue}", 1);
document.styleS heets[0].insertRule("p {color:green; font-size:120%}", 1);
document.styleS heets[0].insertRule("di v.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 AccessibilitySt yleSheet = document.create StyleSheet("Acc essibility style sheet", "projection,scr een,tv");
It should have been written rather
var AccessibilitySt yleSheet = document.create CSSStyleSheet(" Accessibility style sheet", "projection,scr een,tv");
No, it should be
document.implem entation.create CSSStyleSheet(. .., ...)
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.ne t> 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
some later point in the text I don't want to use the bullet point with
an image, but rather use the standard bullet point. Is it possible to
switch off a style sheet instruction for an individual instance? Or do
I need to define a new style...
|
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 nothing in IE.
I'd be greatful for any assistance. Also, if I will have problems the
code on Opera or Safari, I'd appreciate any pointers--I don't have a
Mac to test Safari.
THanks very much,
Michael
|
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, (z-index: 2),
minimized to 20px x 20px width & height, using the box model. These 10,
(point0 to point9), are positioned on the map with the position style.
These small images should then enlarge when the mouse hovers over them,
(z-index: 3).
|
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 language=javascript>
function changeclass()
{document.getElementById(id).className="class_id";}
</script>
<input type=checkbox onclick="javascript:changeclass()">
|
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 retrieved yet. Vadym
Stetsyak suggested me to use singleton, it seems a good solution for me, but
after I read more about singleton, I find another issue - if I use singleton
patter, I can not store context data in the class anymore. How I used...
| |
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 answer is no, since these
will only exist in the browser whereas the code-behind runs on the web
server, but I wanted verification from you experts out there (I'm new to
ASP.NET).
If the answer is no, is it possible via javascript ?
|
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 concrete class but with empty method
implementation of course since WSDL does not provide any info on
implementation.
Thanks
M.
|
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 problems and this one is really getting to me...
I have a page that allows you to Browse Authors. There are three drop down boxes that auto-populate via AJAX. I have a file which it calls and returns the dynamically built XML file in the boxes...
|
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 Web Content Form? I cannot
use style tags in a Web Content Form, and I am having trouble figuring out
how to add all the desired css properties to a
System.Web.UI.WebControls.Style object. Can anyone help me? Thanks.
--
Nathan Sokalski...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |