In the below code, if I specify the property value like doc.styleSheets[0].rules[0].style.fontweight
, it works but if I pass a variable, it throws the error. Why is it?
html =
(Ltrim
<html>
<head>
<style type="text/css">
div {
font-weight: bold;
}
</style>
</head>
</html>
)
doc := ComObjCreate("HTMLfile")
doc.write(html)
ChangeCSSRules(doc, "fontweight", "normal")
msgbox % doc.documentElement.innerHTML
ChangeCSSRules(doc, property, value) {
doc.styleSheets[0].rules[0].style[property] := value ; this causes "Error: 0x80020003 - Member not found."
; doc.styleSheets[0].rules[0].style.fontweight := "normal" ; this works
}
It seems that using [] causes that error.
html =
(Ltrim
<html>
<head>
<style type="text/css">
div {
font-weight: bold;
}
</style>
</head>
</html>
)
doc := ComObjCreate("HTMLfile")
doc.write(html)
doc.styleSheets[0].rules[0].style["fontweight"] := "normal" ; this causes "Error: 0x80020003 - Member not found."
; doc.styleSheets[0].rules[0].style.fontweight := "normal" ; this works
msgbox % doc.documentElement.innerHTML
As i know it, it's because some properties of COM objects can accept parameters
That is a
Known limitation:
Currently x.y[z]() is treated as x["y", z](), which is not supported. As a workaround, (x.y)[z]() evaluates x.y first, then uses the result as the target of the method call. Note that x.y[z].() does not have this limitation since it is evaluated the same as (x.y[z]).().
try it like this
test:="fontweight"
(doc.styleSheets[0].rules[0].style)[test] := "normal"
Hope it helps
best.
BlackHolyman
User contributions licensed under CC BY-SA 3.0