Jump to content

Autoit how to implement javascript functions?


Recommended Posts

Hello coders. I've been working with the FF.au3 extension which allows user to do things in Firefox via javascript (_FFCmd function sends javascript and then returns values)

But in a lot of cases, there may come handy a javascript function, and now I found that it is probably essential to implement one. The case is:

http://stackoverflow.com/questions/15055185/document-getelementsbyclassname-exact-match-to-class

I've got elements with class "item" and class "item one"
if I do

_FFCmd("someMoreThings.getElementsByClassName('item')")

, it picks the items "item one" also. I need to pick only "item". That issue is solved by a javascript/jquery function on stackoverflow forum. How can I do something like that in AutoIt?

Thanks for help, Knuckles

EDIT: I'm thinking of using something like this:

document.getElementsByClassName('item' && !'item one');

JSLint says Weird condition. (so it's probably not the right way to do it)

Edited by knucklesCZ
Link to comment
Share on other sites

Some people say thar SRE in html is madness, but I still use it xD
 
SRE:
$rex = StringRegExp($htmlPage,'(?ims)<div class="item">(.+?)</div>',3) ;returns an array

Matching where the string beggins and where the </div> is used

$Start = StringInStr($htmlPage,'class="item">') ;matches the beginning of class="...
$end = StringInStr($htmlPage,'</div>',0,1,$Start) ;matches the char count of </div> (began matching it from $Start)
$match = StringMid($htmlPage,$Start+13,$end-$Start-12)

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...