I'm not 100% sure what question I should ask - as I'm too sure on the best way to do this .. so let me describe what I'm trying to do (using a simplified example) and we'll go from there.
You have arbitrary HTML Elements (IMG, A, TD, whatever). Via the CSS they are assigned an HTML Behavior
.BoldSelection {
behavior: url(SelectBold.htc);
border: thin solid black;
}
The Behavior simply puts a thick border around the elements when they are clicked - BUT - they have to set the previously selected element with a normal border.
So here is the HTC source. This would work if CurrentlyFocusedElementID was static between all instances of the behavior. But it isn't.
<Public:Attach Event="onContentReady" onEvent="LoadInit" />
<Script Language="VBScript" type="Text/VBScript">
Sub LoadInit
element.onClick = getRef("setFocusedElement")
End Sub
Sub setFocusedElement
set ele = document.getElementByID(CurrentlyFocusedElementID)
ele.style.border = "thin solid black"
CurrentlyFocusedElementID = element.id
element.style.border = "thick solid black"
End Sub
</Script>
I also thought that if I could store an arbitrary property or attribute within the containing document's DOM then I could use that as a common place to look for the last active element ... alas I can't figure out a way to do that without using some sort of hack (ie. hijacking the body's class value)
I would like to keep the code all contained within the HTC. I like the modular fashion of doing it this way .. that way I can simply assign the CSS Behavior and its done - no callbacks .. no parent attributes .. no HTML Components to declare.
How would you suggest I go about doing this?
Thank you in advance.
The missing piece of the puzzle was .. expandos. Custom arbitrary attributes. Here is the completed .HTC