P
P
pixx2010-10-09 18:51:10
JavaScript
pixx, 2010-10-09 18:51:10

Algorithm for detecting visually hidden HTMLDom elements?

There is a task: programmatically determine the list of hidden (not visible to the eye) html elements from the html page code.
The first thing that comes to mind is to take node.js + jquery ( habrahabr.ru/blogs/javascript/104761 ) and play with the :visible pseudo-selector , but there is a doubt that css files will not be taken into account in this case.

Question for connoisseurs: is it possible to teach this link to take into account css files and how to do it?

PS. I will also be grateful for other ways to solve the problem based on linux.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
M
m00t, 2010-10-11
@pixx

If it doesn’t break running a full-fledged browser on the server, look towards Selenium. We had experience writing parsers / grabbers on it - there is an API for almost any language (they wrote in PHP themselves).
Briefly about it: the browser is launched, and work is carried out directly with the page already rendered in the browser. So both css and $('#element').hide() are processed.
Plus, launching “to play and see” is quite simple, which is not unimportant.

Y
yadaya, 2010-10-09
@yadaya

I would:
1. Parse CSS for :hidden, resulting in an array of styles hiding elements.
2. HTML parsing including only elements with :hidden and styling from the CSS array (item 1).
Parsing is already more convenient for anyone +)

A
Aquahawk, 2010-10-09
@Aquahawk

This is not possible within the scope of the task. Formulate the task more specifically. Because the width of the screen of the display device will change the visibility of objects. When I wrote antispam for WordPress, I moved the standard input form 3000 pixels to the left, and did not set it to :hidden, because some bots parse :hidden. From the user's point of view, neither is visible. Another thing is if you need to find elements that can never be shown, this is already a more realistic task.

N
nikel303, 2010-10-10
@nikel303

Maybe so?
offsetHeight == 0? hidden: visible

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question