質問

I am trying to get the font size of selected range in a html document. I used queryCommandValue to get it. Some times it return an integer. And some times it is not. I don't know what is it.

And I also tried another way to get the fontsize by getting the parent emlement's style. But it's not always correct for there could be different font size in its children.

役に立ちましたか?

解決

This method returns a value between 1 and 7, for font sizes from "small" to "large", like in GMail.

If you want to get a font size in points or pixels, use

mshtml.IHTMLTxtRange range = _dom.selection.createRange() as mshtml.IHTMLTxtRange;
if (range != null)
{
   mshtml.IHTMLElement2 elem = range.parentElement() as mshtml.IHTMLElement2;
   fontSize.Text = elem.currentStyle.fontSize.ToString()
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top