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

Detecting CSS State

I did a search and basically came up with nothing for this question,
but if I missed the answer, I apologize in advance, please just point
me in the right direction.

OK, I am using a JavaScript generated menu on my site; with CSS enabled
it looks great, but when CSS is disabled it prints out all these menu
options inline and you have to scroll past them (a pain in the ass). Is
there any way to tell if the user has CSS enabled or disabled through
JavaScript? I need a solution that works on Netscape, Mozilla (and
Firefox), IE, and preferably Opera. Any suggestions?

If you want to see what I mean check out
http://www.activelock.org/demo_site with CSS disabled (if you use
Firefox with the Web Developer plug-in its really easy, just
CTRL+SHIFT+D).

..:Mike Crute:.

Jul 23 '05 #1
7 1831
Michael Crute wrote:
I did a search and basically came up with nothing for this question,
You didn't search this new group, else you would have found an almost
identical question on 3 Dec with the subject "CSS enabled", to which
Mike Winter's uncontested response was:

"I don't believe you can."
but if I missed the answer, I apologize in advance, please just point
me in the right direction.
Apology accepted... :-p

OK, I am using a JavaScript generated menu on my site; with CSS enabled
it looks great, but when CSS is disabled it prints out all these menu
options inline and you have to scroll past them (a pain in the ass). Is
there any way to tell if the user has CSS enabled or disabled through
JavaScript? I need a solution that works on Netscape, Mozilla (and
Firefox), IE, and preferably Opera. Any suggestions?
No.

If you want to see what I mean check out
http://www.activelock.org/demo_site with CSS disabled (if you use
Firefox with the Web Developer plug-in its really easy, just
CTRL+SHIFT+D).


Your menus fail completely if JavaScript is turned off, which is
probably more prevalent than browsers without CSS support. Have you
considered that issue?

--
Fred
Jul 23 '05 #2
Mike,
The following works accurately with firefox and assumes there is only one
stylesheet (styleSheets[0] = array item 1) embedded in the doc. I don't know
what it would do with inline or @import styles.

I'm sure you could create a function to accomodate those variables if there are
more style sheets.

I put this in the body tag so that onLoad, if the stylesheet is disabled (by
firefox) you will be whisked off to yahoo.com, which assumeably is what you'd
want to do with a user: redirect them to a user-friendly non-css page ??

onLoad='if(document.styleSheets[0].disabled){location.href="http://www.yah
oo.com";}'

Obviously this needs testing in other browsers with their respective css
zappers, but it does work with firefox, so that's a positive start! ;-)

Hope this helps!

Jim
Jul 23 '05 #3
On 13 Dec 2004 19:53:38 -0800, Michael Crute <mc****@gmail.com> wrote:

[snip]
OK, I am using a JavaScript generated menu on my site; with CSS enabled
it looks great, but when CSS is disabled it prints out all these menu
options inline and you have to scroll past them (a pain in the ass).
[...] Any suggestions?


Place the list at the end of the document, not the start, and position it
with CSS. Also, notice I said list: those links should be rendered with a
styled unordered list.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #4
On 15 Dec 2004 05:34:54 GMT, JimMenees <ji*******@aol.comNoSpam> wrote:

[snip]
I put this in the body tag so that onLoad, if the stylesheet is disabled
(by firefox) you will be whisked off to yahoo.com, which assumeably is
what you'd want to do with a user: redirect them to a user-friendly
non-css page ??
Considering that CSS is optional, all documents should be user-friendly,
but not particularly attractive, when CSS is disabled.
onLoad='if(document.styleSheets[0].disabled){
location.href="http://www.yahoo.com";}'


That certainly won't work with Opera as it doesn't currently implement the
styleSheets collection. Moreover, redirects should not be accomplished
with Javascript.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #5
Jim... thanks for the code it is a good start. As far as IE and other
browsers go, is there a little tool to disable CSS?

Michael... i think you have a good idea putting the list at the end.
The problem is though that if css is disabled I don't want to show the
list period. The rest of the page renders fine with CSS disabled but
the menu is just an annoying "feature" if there is no CSS.

The menu that I am using was generated with Macromedia Fireworks and
hacked to fit my needs. I may have to rewrite the entire Fireworks JS
code to make it more browser friendly, but I would rather not :)

Jul 23 '05 #6
On 16 Dec 2004 11:50:09 -0800, "Michael Crute" <mc****@gmail.com>
wrote:
Jim... thanks for the code it is a good start. As far as IE and other
browsers go, is there a little tool to disable CSS?


you don't need a tool, it's built into the browser.

Jim.
Jul 23 '05 #7
Hmm... I have never heard of such a thing, but I haven't really even
opened IE since before Firefox .08 :)

Jul 23 '05 #8

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

Similar topics

11
by: Adam Parkin | last post by:
Hello all, I need to be able to detect if there is an active available Internet connection in my VB6 program. In my program I'm using the Internet Transfer Control to transfer some files by HTTP,...
6
by: Querejeto | last post by:
Hello: Is it possible to detect programmatically the constness of a member function when it is called? That is, I would like to see a generic implementation (i.e. it does not depend on the...
6
by: Thomas Mlynarczyk | last post by:
Hi, Say I have an array containing a reference to itself: $myArray = array(); $myArray =& $myArray; How can I, looping iteratively through the array, detect the fact that $myArray will "take"...
7
by: fox | last post by:
Maybe this is not the best group to ask this question, but I don't know a better one. I'm looking for a *portable* program in C (I mean source code) to detect whether unaligned word access is:...
2
by: Anthony | last post by:
In C++ you can detect the screensaver state by using something like: BOOL b=SystemParametersInfo(SPI_GETSCREENSAVERRUNNING, NULL, &bOn, FALSE); Is there an equivalent method that I can use in...
6
by: Andrea | last post by:
I need to detect when another application is launched. I'd need to know also when a new folder is opened in explorer. I'm developing an application to speed up access to frequently used...
2
by: ASP.Confused | last post by:
How would I go about detecting a memory leak? My web hosting provider has our site set up to only have a root "bin" folder for .NET apps, and I would like to be able to watch how much memory is...
7
by: glen | last post by:
I'm looking for a way to detect if another process has a file open before a second process tries to open it. I've looked into the FileAttr function but I'm not sure if detecting a read-only state...
5
by: Bob | last post by:
Using Vs 2005 and Vb.NET I want to give users a message asking if they're sure they want to close the form if they had made changes to the underlying data. How do I detect if changes had been made...
12
by: ABN | last post by:
I have a C# (.NET 1.1) application in which I loop over a number of files on the hard drive and delete them. A few times, I've experienced an exception that says the file is in use by another...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

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.