PDA

View Full Version : Big Problems


timur
03-06-2003, 02:30 PM
Hi. I've suffered such a problem:

I've got a WYSIWYG editor (content editabe iFrame)

i'm adding rules to some tags:

oClassName = '.class' + Math.round(Math.random() * 1000);
oStyleSheet = myIrrame.document.createStyleSheet('style.css');
oStyleSheet.addRule(oClassName + ':hover', 'color: #ff0000;');
oLink.className = oClassName.substr(1);

but when i'm saving my document there is no hover.

GoHF
03-06-2003, 02:52 PM
Have you ever seen anything like that work?

According to this page, there is no way to set ":hover" programatically:
http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/hover.asp (notice the "Scripting: N/A" on the first table)

So, you may have run into one of IE's many many bugs... or maibe just laziness from the coders.

timur
03-06-2003, 02:59 PM
Yes I saw this MSDN page, but if you'd read carefully you'll understood that they means that the hover can't be used as a property.

My exampe is 100% working until i save my document. The IE bugs has nothing with it. All i need is a tip of how to save styles added with help of addRule method.

timur
03-06-2003, 03:01 PM
I don't think that MS coders may be blamed for that 'cos hover is sub-class of a class.

GoHF
03-06-2003, 07:53 PM
Sorry for my silly comment =)

Anyway, more MSDN checking. I have no idea how you are saving your document, but you can access the rules on a Stylesheet by using:

stylesheet.rules[ruleIndex]

to know the name of a rule, use the selectorText property

stylesheet.rules[ruleIndex].selectorText

This returns the name of the class, even with the ":hover". Maibe this can help?

timur
03-07-2003, 09:55 AM
ok, i'll try to recompose my question.

Is it possible to save rules added by addRule method ?

timur
03-07-2003, 10:15 AM
ok, the solution has been found.

for(key in document.styleSheets){
myCssSavingFunction(document.styleSheets[key]);
}

beg your pardon for wasting your time

Roy Sinclair
03-07-2003, 09:49 PM
beg your pardon for wasting your time

Not a waste of time when you come back and post the solution (as you did).:thumbsup:

timur
03-10-2003, 08:56 AM
thanks Roy