Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html Webbrowser控件将样式添加到已具有样式的标记_Html_Css_Vb6_Webbrowser Control - Fatal编程技术网

Html Webbrowser控件将样式添加到已具有样式的标记

Html Webbrowser控件将样式添加到已具有样式的标记,html,css,vb6,webbrowser-control,Html,Css,Vb6,Webbrowser Control,在vb6 web浏览器控件中,我想为backgrpund颜色设置style属性 If P.getAttribute("name") = "mybookmark" Then P.Style.cssText = "background-color:#FFFFEB" End If 但是如果我这样做,那么它会覆盖样式属性(如果已经存在)。例如,如果存在带有abc的html标记,则“我的代码”将删除现有的“样式添加背景色”属性。那么如何为现有样式添加样式属性呢?添加到现有样式,而不是替换它:)

在vb6 web浏览器控件中,我想为backgrpund颜色设置style属性

If P.getAttribute("name") = "mybookmark" Then
    P.Style.cssText = "background-color:#FFFFEB"
End If

但是如果我这样做,那么它会覆盖样式属性(如果已经存在)。例如,如果存在带有
abc
的html标记,则“我的代码”将删除现有的“样式添加背景色”属性。那么如何为现有样式添加样式属性呢?

添加到现有样式,而不是替换它:)


p.Style.cssText=“background color:#FFFFEB;”&p.Style.cssText

我这么做已经很久了,但是你有没有试过
p.Style.cssText=“background color:#FFFFEB;”
&p.Style.cssText`?@Fred工作得很好!!。。请将其作为答案发布,以便我可以将其标记为答案。我认为您最好使用P.Style.cssText&“背景色:#FFFFEB;”。基本上,在现有样式之后而不是之前添加背景色。我不确定,但我认为如果已经为其设置了背景色,那么将背景色放在现有样式之前是行不通的,而将其放在will之后是行不通的。@GMastros这是我第一次写的,但后来想到了分号。现有字符串的末尾是否有分号。我没有测试它,而是将它添加到字符串的开头。但是,您确实提出了一个需要测试的有效点。