无法使用DOM访问font-weight属性 [英] Cannot access font-weight property with DOM

查看:149
本文介绍了无法使用DOM访问font-weight属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了使用DOM访问font-weight属性的麻烦。

  html = 
(Ltrim
< html>
< head>
< style type =text / css>
#bar {
border:1px solid black;
}
div {
font-weight: bold;
}
< / style>
< / head>
< body>< div> foo< / div>< p id =bar > bar< / p>< / body>
< / html>


doc:= ComObjCreate(HTMLfile)
doc.write (html)
msgbox%doc.styleSheets [0] .rules [0] .style.border; black 1px solid
msgbox%doc.styleSheets [0] .rules [1] .style.font-weight;没有
msgbox%doc.styleSheets [0] .rules [1] .style [font-weight]; [object]

这应该是这样吗?或者最后两个消息框是否显示值bold?

解决方案

- 减号用于数学运算,不能用于变量名,因此您遇到的错误。



尝试一些类似 Object.style.fontWeight =value,如 http:/ /www.w3schools.com/jsref/prop_style_fontweight.asp


I'm having troubles accessing the font-weight property with DOM.

html =
(Ltrim
    <html>
    <head>
    <style type="text/css">
    #bar{
        border: 1px solid black;
    }
    div {
        font-weight: bold;
    }
    </style>
    </head>
    <body><div>foo</div><p id="bar">bar</p></body>
    </html>
)

doc := ComObjCreate("HTMLfile") 
doc.write(html)
msgbox % doc.styleSheets[0].rules[0].style.border           ; "black 1px solid"
msgbox % doc.styleSheets[0].rules[1].style.font-weight      ; nothing
msgbox % doc.styleSheets[0].rules[1].style["font-weight"]   ; "[object]"

Is this supposed to be this way? Or should the last two message boxes show the value "bold"?

解决方案

The - Minus sign is used in mathematical operations and cannot be used in a variable name, hence the error you are experiencing.

Try something like Object.style.fontWeight="value" as suggested at http://www.w3schools.com/jsref/prop_style_fontweight.asp

这篇关于无法使用DOM访问font-weight属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆