0

I'm developing an android application which takes its information from a site that use JavaScript.

I want to run one of the java script function through my android app.

in example: this site http://www.bgu.co.il/tremp.aspx has "Next page" in the bottom (in hebrew) that javascript function do. i want to get to the next page through my app.

How can i send the site the command "move to next page" or activate button's onClick event?

EDIT: I'm taking information from this site, using an XML parser (sax parser), I want to get to the next page of this site in order to parse it either. I hope I made myself clear now

3 Answers 3

1

You really need to explain a little more fully...

Are you opening that page and parsing it in your code, have you embedded a WebView or are you just creating an Intent which opens that page in the user's preferred web-browser?

If the latter, then you definately cannot do what you're suggesting.

If you're using a WebView I'm pretty sure you still can't access the DOM of the page in the way you want to

That means your solution is to load and parse the webpage in your code - extract the 'next' page and then do with that whatever you wish...

Sign up to request clarification or add additional context in comments.

1 Comment

I'm taking information from this site, using an XML parser (sax parser), I want to get to the next page of this site in order to parse it either. I hope I made myself clear now
1

Check out the Using JavaScript in WebView section in the Android Developer Guide

2 Comments

Thanx, but i'm not using WebView... so it won't help me
Hmm, I would think that the WebView method addJavaScriptInterface does what you need developer.android.com/reference/android/webkit/…, java.lang.String)
0

OK - now we know you're parsing the page I can try to answer your question!

You can't "click" something on a parsed page because you have no Javascript engine - it's just an XML document - a collection of nodes made-up of text.

In this case you need to work-out how the paging system actually works - and looking at the page in something like Firebug makes that quite simple to do.

The paging system works through a FORM POST mechanism - when you click 'Next' or a page number like '2' it simply loads the same page from the server, but with POST variables set.

The key variable is "__EVENTTARGET" - it tells ASP which page to load (in Hebrew of course).

The snag is that you'll need to pass all the other POST variables from this page too - that's every INPUT with it's associated value. I notice there's one called "_EVENTVALIDATION" which appears to exist to stop people getting around this too-easily by just passing "_EVENTTARGET".

A tool like Fiddler would be useful here too - it will show what is POSTed to the server when you click NEXT - all you have to do is replicate that in your call to load the page again and you have the next page - and repeat that with each page until there's nothing left to load...

Alternatively, you could switch to using a WebView - loading the page into that would mean it does have a Javascript engine and you could automate the 'clicking' (although I don't know the specifics of how to do that, the other answers allude that it's possible?) ?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.