[webkit-help] getElementsByTagName returns 0-length list

Emerick Rogul emerick at gmail.com
Wed May 26 10:53:08 PDT 2010


I'm using the Chromium port of WebKit on Windows and I'm trying to
retrieve a list of all of the images in my document.  I figured the best
way to do this was to implement WebKit::WebFrameClient::didFinishLoading
like so:

WebNodeList list = document->getElementsByTagName(L"img");
for (size_t i = 0; i < list.length(); ++i) {
  // Manipulate images here...
}

However, when this delegate fires, list.length() returns 0.  The only
times I've seen it return a list of non-zero length were when I
substituted "body" or "head" for "img".  Strangely enough, if I call
getElementsByTagName(L"img") _outside_ of the delegate, it works
correctly.

I'm guessing that the DOM isn't fully loaded when didFinishLoading is
called, but that would seem to contradict the delegate's name.  Does
anyone know what I may be missing here?

Emerick



More information about the webkit-help mailing list