Stuck for days....can't change styleSheets through Java script
Hi All
I've been stuck literally for 24 hours or more trying to figure out how to change a styleSheet attribute inside a Java function, instead of calling it using 'href".
Basically what I'm doing is using PHP OpenChat and I'm just wanting to change the background room picture when going from one "room" to another, by clicking an html tag: "SHOW ROOM 4 PICTURE". There are 4 different rooms, each a different stylesheet (1-4).
The function works well enough executed inside the template (.tpl) file:
(within js file)
function ChangeRooms()
{
document.styleSheets[0].disabled=true;
document.styleSheets[1].disabled=true;
document.styleSheets[2].disabled=true;
document.styleSheets[3].disabled=false;
};
No go.
How do you refer to the element "styleSheets[1]" for instance, inside the JavaScript file?
This is only one possible example I've tried, I've tried every combination of 'getElementById', 'getElementsByName', etc, etc, etc.
No matter what combination I try won't work at all. I've poured over reams of Google articles. Nothing works.
Has anyone any ideas? I am no Java expert but this has been a needle in a haystack search for me.
Thanks for any ideas.....
I have a screen refresh routine, but I was using this one....separately.
That one DOES work, and I can call it in the Java script from the tpl:
function Refresh()
{
var i, a, s;
a = document.getElementsByTagName('link');
for (i = 0; i < a.length; i++) {
s = a[i];
if (s.rel.toLowerCase().indexOf('stylesheet') >= 0 && s.href) {
var h = s.href.replace(/(&|%5C?)forceReload=\d+/, '');
s.href = h + (h.indexOf('?') >= 0 ? '&': '?') + 'forceReload=' + (new Date().valueOf())
}
}
};
Does this mean what I posted may be correct otherwise? I'm groping in the dark..............
<a href="javascript:document.styleSheets[0].disabled=true;
document.styleSheets[1].disabled=true;
document.styleSheets[2].disabled=false;
document.styleSheets[3].disabled=true;
parent.Refresh(); /* call refresh subroutine, this works */
">SHOW ROOM THREE PICTURE</a>
That works. But I don't want to do this in the tpl called from an href statement like this manually for each room. There has to be some way I can call it as a subroutine in the JavaScript file.
I need to figure out how to do that, because eventually I'm going to call the room background change in an "ONCHANGE" statement. There is a drop-down box which lists the rooms, and so then I can put the all to the function in there and when the user navigates around different rooms, they will see different pictures.
I'm doing this in baby-steps, crawling slowly across the broken glass..........lol
((eventually will call it from this routine, instead of clicking an html link)))
So there's 4 css files, each one with a different room picture.
So eventually, you click the drop-down box, change rooms, and the room picture changes.
Bookmarks