This is a discussion on "Possible to detect which stylesheet in use?" within the JavaScript Forum section. This forum, and the thread "Possible to detect which stylesheet in use? are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Possible to detect which stylesheet in use?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Possible to detect which stylesheet in use?
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:
Thanks. |
|
|
|
#2
|
||||
|
||||
|
Re: Possible to detect which stylesheet in use?
|
|
#3
|
|||
|
|||
|
Re: Possible to detect which stylesheet in use?
Quote:
I am only able to manipulate/edit the page within the <BODY> section. So... I need to DETECT which Stylesheet is specifically being used within the <LINK> tag without an "id". There are a few different stylesheets that are being used. I need to know which stylesheet is the CURRENT one so that I can counter-code (if that's a real word ) specific font colors, background colors, etc.If you need futher explanation, I'll be happy to give deeper descriptions. But I think that I've covered the situation. Thanks. |
|
#4
|
||||
|
||||
|
Re: Possible to detect which stylesheet in use?
Well, if there is no way to directly identify the current stylesheet, there's obviously no way JavaScript can do it...
|
|
#5
|
||||
|
||||
|
Re: Possible to detect which stylesheet in use?
Er, I should've asked this before, why can't you edit the head tags? That seems rather silly to me.
|
|
#6
|
|||
|
|||
|
Re: Possible to detect which stylesheet in use?
1. I am being "fed" a wrapper for the page. Then I put my content inside the <BODY> of the page.
2. I can see the stylesheet (i.e.: main.css, etc.) that I'm being "fed" in the <HEAD> in the HTML SOURCE, but I can't change the stylesheet. |
|
#7
|
|||
|
|||
|
Re: Possible to detect which stylesheet in use?
You can use JavaScript to pick up the link tag(s) and look at its/their attirbute values.
Use the getElementByTagName('tagname'); function. This actually returns a zero indexed array. |
|
#8
|
||||
|
||||
|
Re: Possible to detect which stylesheet in use?
Yeah, but if there are more than one link tags, there is no way to identify which one is the active stylesheet.
|
|
#9
|
|||
|
|||
|
Re: Possible to detect which stylesheet in use?
I agree... luckily, the particular site that I'm working with only has one <LINK> tag.
So... here is the script that I was looking for:
Like so... (*Although I haven't tested the specific code below - this is the idea behind what I'm trying say - so no need to write back to tell me if this script works or not ... unless you feel like posting a correct functional version for others.)
Thanks to all for the help. |
|
#10
|
||||
|
||||
|
Re: Possible to detect which stylesheet in use?
Don't forget you can have more than one rel="stylesheet" on a site. I use three on most of my pages... If it's going to be consistant, then you're set!
|
![]() |
| Tags |
| javascript detect stylesheet |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Popup Name Detect | RobinDeanDotCom | JavaScript Forum | 0 | Feb 24th, 2007 22:35 |
| Script to detect flash? | fezunit | JavaScript Forum | 5 | Jan 28th, 2007 12:18 |
| Detect IE | Totti | JavaScript Forum | 4 | Dec 6th, 2006 00:48 |
| Detect whether connection to external url is possible | simonneaves | Classic ASP | 3 | Oct 24th, 2005 13:12 |
| detect pop-up blocker - different | bert | JavaScript Forum | 0 | Jul 22nd, 2005 10:30 |