some questions about html element

1. how can i determine if a html element is visible, means doesn't need to scroll to see it

(i was trying to use ScrollToView function but it moves the element to the top/bottom of the window although it's already visible)

2. how can i determine if it's displyed on the doc and not hidden, like text under menu

(i want to search a text in the page but not in the menus or other hidden elements)

any ideas

thanks... Amir.




Answer this question

some questions about html element

  • gdubya

    found the answer to question 2:

    instead of using "style" property of IHTMLElement, use the "current style" property of IHTMLElement2, like this:

    CComQIPtr<IHTMLElement2> elem2 = elem;

    CComPtr<IHTMLCurrentStyle> style;

    HRESULT hr = elem2->get_currentStyle(&style);

    if(style)

    {

    hr = style->get_visibility(&visibility);

    if(visibility == _T("hidden")) return true;

    hr = style->get_display(&display);

    if(display == _T("none")) return true;

    }

    note that you also need to check the element's parents.



  • some questions about html element