在下面的代码中,如果我指定属性值如doc.styleSheets[0].rules[0].style.fontweight
,它可以工作,但如果我传递一个变量,它会抛出错误。为什么?
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
}
似乎使用 [] 会导致该错误。
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