|
|
|
date: Wed, 2 Jan 2008 01:20:34 -0800 (PST),
group: microsoft.public.inetsdk.programming.webbrowser_ctl
back
With iframe, offsetLeft of IHTMLElement is bigger than expected.
Hello, Happy new year~
I must get location of element on web page.
I typed below to get offsetLeft of element.
// m_SelectedElem is declared as IHTMLElement
int nLeft = 0;
int nTop = 0;
nLeft = m_SelectedElem.offsetLeft;
nTop = m_SelectedElem.offsetTop;
Console.WriteLine("{0} {1}", nLeft, nTop);
IHTMLElement l_tmpElem =
m_SelectedElem.offsetParent;
while (l_tmpElem != null)
{
nLeft += l_tmpElem.offsetLeft;
nTop += l_tmpElem.offsetTop;
Console.WriteLine("{0} {1}", nLeft, nTop);
l_tmpElem = l_tmpElem.offsetParent;
}
Generally, nLeft and nTop might get almost correct value after
expending web browser as proper size.
By the way, sometimes in the case element include iframe, that value
might be bigger than I expected.
I don't know why that value is different.
Have you ever got this situation before, have any solution?
Best regards.
date: Wed, 2 Jan 2008 01:20:34 -0800 (PST)
author: Diainwater
|
|