Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
inet
active_desktop
active_scrptng
asp.components
asp.db
asp.general
comctl32
comp.packaging
components.dev
dbweb
dhtml_editing
docobjects
html_authoring
html_objmodel
iis
iis.ftp
iis.security
iis.smtp_nntp
indexserver
misc
mshtml_hosting
scripting.jscript
scripting.vbscript
sdk_setup
shell_objmodel
urlmonikers
webbrowser_ctl
wininet
  
 
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

Re: With iframe, offsetLeft of IHTMLElement is bigger than expected.   
Diainwater  wrote:
> I must get location of element on web page.

See if this helps:

http://groups.google.com/group/microsoft.public.inetsdk.programming.webbrowser_ctl/browse_frm/thread/f74426178c365051

-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Wed, 2 Jan 2008 11:30:45 -0500   author:   Igor Tandetnik

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us