In my Cocoa (Mac) application, I am utilizing a Webview and trying to determine the accurate height of a document. While the typical method
webview.mainFrame.frameView.documentView.bounds.size.height
works well in most cases, I encountered an issue with one specific website:
.
On this site, retrieving the document height using the above approach gives me around 500, even though the actual height is over 2000 since scrolling multiple screens reveals more content.
I attempted using JavaScript evaluation within the webview to obtain the correct height by following methods mentioned in resources like: How to get height of entire document with JavaScript?
Unfortunately, these methods also provided inaccurate values similar to my initial attempt. Even after loading jQuery on the page and using $(document.body).height(), the result was incorrect. Does anyone have insights into what might be causing this discrepancy? Is there a reliable alternative for determining the document height?
I observed discrepancies in the inspector tool in Chrome as well. The reported heights were inaccurate, with instances where the body height was less than that of its child nodes as depicted in the screenshots.