473,382 Members | 1,392 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,382 software developers and data experts.

Accessing stylesheets from javascript

I'm looking for a way to do:

function resetBorder(theObj) {
theObj.style.border = theObj.class.border;
}

But it doesn't seem to be as simple as that :)
I'd like a cross-browser solution, but will settle for IE.

Love some help!
Cheers
Rick
Jul 20 '05 #1
3 1984


Rick Measham wrote:
I'm looking for a way to do:

function resetBorder(theObj) {
theObj.style.border = theObj.class.border;
}

But it doesn't seem to be as simple as that :)
I'd like a cross-browser solution, but will settle for IE.


I am not sure what
theObj.class.border
is supposed to yield but I suspect you want to reset the inline style so
that any existing style sheet takes over. The right way to achieve that
is with
theObj.style.border = '';
as that clears the inline style and then the stylesheet kicks in.
Should work with IE4+, Netscape 6+, Opera 7.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin Honnen wrote:

Rick Measham wrote:
I'm looking for a way to do:

function resetBorder(theObj) {
theObj.style.border = theObj.class.border;
}

But it doesn't seem to be as simple as that :)
I'd like a cross-browser solution, but will settle for IE.


I am not sure what
theObj.class.border
is supposed to yield but I suspect you want to reset the inline style so
that any existing style sheet takes over. The right way to achieve that
is with
theObj.style.border = '';
as that clears the inline style and then the stylesheet kicks in.
Should work with IE4+, Netscape 6+, Opera 7.


That's what I'm trying to do, and it works with IE5 for Mac. However IE6 for
Win thinks that theObj.style.border='' is the same as no border. So what I
wanted to do was access the border property of the class assigned to the
object and apply said border as a style.

--
Obviously the reply-to is a fake. Just change the 'spam-' to 'i' so that the
result sounds like why you go to an optometerist.
Jul 20 '05 #3
"RIck Measham" <ri***@spam-site.net.au> wrote in message
news:3f**********************@news.optusnet.com.au ...
Martin Honnen wrote:

Rick Measham wrote:
I'm looking for a way to do:

function resetBorder(theObj) {
theObj.style.border = theObj.class.border;
}

But it doesn't seem to be as simple as that :)
I'd like a cross-browser solution, but will settle for IE.
I am not sure what
theObj.class.border
is supposed to yield but I suspect you want to reset the inline style so
that any existing style sheet takes over. The right way to achieve that
is with
theObj.style.border = '';
as that clears the inline style and then the stylesheet kicks in.
Should work with IE4+, Netscape 6+, Opera 7.


That's what I'm trying to do, and it works with IE5 for Mac. However IE6

for Win thinks that theObj.style.border='' is the same as no border. So what I
wanted to do was access the border property of the class assigned to the
object and apply said border as a style.

Re: theObj.class.border

Is 'border' a CSS class name? If so you can simply rewrite as follows:

theObj.className = 'border'

Or, you can simply reapply the className originally assigned to the object
(assuming that you've subsequently modified 'theObj.style' properties).


Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: twice a week (mondays and thursdays) Last-modified: March 10, 2001 Version: 1.95 URL: http://css.nu/faq/ciwas-mFAQ.html Maintainer:...
2
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: once a week Last-modified: 2004-07-26 Version: 2.00 URL: <http://css.nu/faq/ciwas-mFAQ.html> Maintainer: Jan Roland Eriksson...
0
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: once a week Last-modified: 2004-07-26 Version: 2.00 URL: <http://css.nu/faq/ciwas-mFAQ.html> Maintainer: Jan Roland Eriksson...
0
by: Jan Roland Eriksson | last post by:
Archive-name: www/stylesheets/newsgroup-faq Posting-Frequency: once a week Last-modified: 2004-07-26 Version: 2.00 URL: <http://css.nu/faq/ciwas-mFAQ.html> Maintainer: Jan Roland Eriksson...
5
by: googlegroups | last post by:
I have a large table in html created dynamically. This table can grow to several hundred rows or more. I have the ability to hide or display individual rows (using row.style.display = "none") and...
37
by: pochartrand | last post by:
Hello, Is there a way to manipulate or at least read the pseudo-class of an element ? I know the style attribute can be accessed and gives the CSS properties for a particular element....
3
by: HugeBob | last post by:
Hi All, Is it possible to access the browser's print header/footer. I want to create a printable version of a page and alter the printout's header and footer. Is this possible? Thanks!
5
by: =?Utf-8?B?bXVzb3NkZXY=?= | last post by:
Hi guys I'm trying to make my code as streamlined as possible, and add CSS file references dynamically when they are required, for example, if a page contains a webcontrol, then the related CSS...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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
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...

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.