Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Just another Perl shrine
 
PerlMonks  

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

by mascip (Pilgrim)
on Jan 31, 2012 at 19:18 UTC ( #951049=note: print w/ replies, xml ) Need Help??


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

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)


Comment on Re^2: WWW::Mechanize - how to get the position of an element on my screen?
Re^3: WWW::Mechanize - how to get the position of an element on my screen?
by Corion (Pope) on Jan 31, 2012 at 19:22 UTC

    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.

      That's an important point and i didn't know it, thank you Corion.

      Would it then be possible for me to pass my HTML::Element to Javascript? Does it make any sense?

      My aim being : finding the element with HTML::Tree, and then retrieving its position with Javascript.

        That's not how things work. Most likely, whatever Javascript or HTML rendering tool you use will also support XPath or CSS selectors. Use these tools instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951049]
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: (16)
As of 2014-04-17 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (453 votes), past polls