Is it possible to use Javascript to detect which stylesheet is currently being used in a page? ... a script to detect the HREF value in the <link> tag which is located in the <HEAD> of the page. IMPORTANT: I need to place this javascript "detect" after the <BODY> tag! (= cannot place this script in the <HEAD>) EXAMPLE: <html> <head> <link rel="stylesheet" href="main.css" type="text/css"> </head> <body> blah, blah.... <script> detectCurrentStylesheetBeingUsed() </script> </body> </html> Code (markup): My guess is that this cannot be done ... but I'd like to hear from others. Thanks.
Try this (works in Explorer and FireFox): <script> hr = document.getElementsByTagName("link")[0].getAttribute('href'); alert( hr ); </script> Code (markup):
Yep! This is the answer. Believe it or not, I almost had this. Stupidly, I was using [1], not [0]! That damn zero! That's why I wasn't getting MY alert to popup the the name of the style. Anyway, thanks for your help!