PDA

View Full Version : Javascript Function execution in html page



saeedIRHA
16th October 2011, 13:39
Hello guys,

i want to reboot my router using my application , but normally it can only be dont by clicking on a button on HTML page which executes a javascript,
and since i cannot include javascript function on hyper-link, is there anyway to execute specific javascript's function on html page using Qt libraries ?

thank you :)

wysota
16th October 2011, 17:54
Find appropriate series of HTTP calls doing the reboot and then implement them with Qt using QNetworkAccessManager or QWebPage.

saeedIRHA
16th October 2011, 19:33
Dear Wysota,
Thank you for your reply, that was what i did , but i couldnot find a way to execute javascript of a HTML page, since i cannot call the reboot directly , and it has to be done through javascript function in a HTML page.
could you please give me an example or direct me in the right path :)

Thank you very much.

wysota
16th October 2011, 21:00
The script invokes some http call. Find that call and call it manually (after you login to the router, of course). Firebug/wireshark will help you find that call.

saeedIRHA
16th October 2011, 21:39
would it be same HTTP call in case i want to change username and password too ?
i am trying to write an application to manage my router.
its quite hard to analyse the javascripts , and i preferred to call javascript function instead of going through all that hassle :(

Thankx once again :)

wysota
17th October 2011, 10:02
would it be same HTTP call in case i want to change username and password too ?
Not the same but similar, yes.


its quite hard to analyse the javascripts , and i preferred to call javascript function instead of going through all that hassle :(
You can use QWebPage to traverse the page and call the scripts, that's not a problem. However every operation will take much longer then and overall the code you need to write will be much more complex. It's really easier to launch firebug in firefox or use chrome to monitor outgoing http traffic to your router. You will then see what requests a particular call invokes. Then it's just a matter of reproducing those calls.

saeedIRHA
17th October 2011, 13:01
Dear Wysota,

Thank you very much for your reply, i managed to find a invoke calls by monitoring HTTP request using wireshark as you recommended.
and now i can send request using QHttp to my router.
Thank you very much for all your help :)