Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

WWW::Mechanize - how to get the position of an element on my screen?

by mascip (Pilgrim)
on Jan 31, 2012 at 18:44 UTC ( #951038=perlquestion: print w/ replies, xml ) Need Help??
mascip has asked for the wisdom of the Perl Monks concerning the following question:

Hello,
i'm new here, and quite new to Perl, WWW::Mechanize and WWW::Mechanize::Firefox.
I'm playing moving around in a page with HTML::TreeBuilder. I get references of the elements (HTML::Element) i need, that all ok.

What i need then, is to retrieve the position of an element on my screen. So, how can i build this get_position_of() function :

my ( $x, $y ) = get_position_of( $my_html_element );

Thank you :o)

Comment on WWW::Mechanize - how to get the position of an element on my screen?
Download Code
Replies are listed 'Best First'.
Re: WWW::Mechanize - how to get the position of an element on my screen?
by Corion (Pope) on Jan 31, 2012 at 19:17 UTC

      The description seems to fit perfectly my needs, thank you !
      I'll get back to you (after eating) about whether and how it worked.

      PS : Forget my answer to your previous message, then.
      PPS : i feel sorry to not have found that function myself, and thus made you work for me. I searched, though, but with "position" as a keyword. And i looked at the module summary, but not at the "image methods".

Re: WWW::Mechanize - how to get the position of an element on my screen?
by Anonymous Monk on Jan 31, 2012 at 19:01 UTC
    http://stackoverflow.com/questions/442404/dynamically-retrieve-html-element-x-y-position-with-javascript

      This is a Javascript solution to get the position of an Element, by retrieving it with its ID.
      It doesn't really answer my question, because the element whose position i want has no ID.
      One could say "use getElementsByTagName, then!" .
      It wouldn't do either : i don't want to have to search my element with Javascript tools.

      I have ALREADY found the element i'm interested in with HTML::Tree, and want to get it's position.
      I could do with Javascript tools if there's no Perl module that gets it for me, but then i'd need to tell Javascript who my element is. I don't know how to do this.

      Thanks for very fast answer, though =o)

        You don't seem to understand. The "position" of an HTML element only exists if the HTML is actually rendered into a layout. HTML::Tree does not do such rendering.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://951038]
Approved by GrandFather
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2015-07-30 09:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (270 votes), past polls