Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

IHTMLElement2.ClientLeft reports different between Win7 and Win8 / Win8.1

$
0
0

Hi All,

I find a issue to get ClientTop and ClientLeft for a IHtmlElement2 object from web browser control on different version combination of IE and WinOS.

Here is the sample to reproduce

        private void Form1_Load(object sender, EventArgs e)
        {



			var input = "<button style=\"\">button</button>";


            webBrowser1.DocumentText = "<html><body></body></html>";

            IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
            doc.designMode = "On";

            webBrowser1.DocumentText = "<html><body>" + input + "</body></html>";
            webBrowser1.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser1_DocumentCompleted);
        }



        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;

			IHTMLElement btn = doc.body.children[0];

MessageBox.Show(String.Format("clientLeft:{0}, clinetTop:{1}",btn.clientLeft,btn.clientTop));
}

The results are

IE9 on Windows 7 : ClientLeft = 2 ClientTop = 2

IE10 on Windows 7 : ClientLeft = 1 ClientTop = 1

IE11 on Windows 7 : ClientLeft = 1 ClientTop = 1

IE10 on Windows 8 : ClientLeft = 2 ClientTop = 2

IE11 on Windows 8.1 : ClientLeft = 2 ClientTop = 2

Any one can explain for this?

Regards,

Yi


MSC on Computer Science (Parallel algorithm)


Viewing all articles
Browse latest Browse all 12583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>