Results 1 to 7 of 7

Thread: Javascript Function execution in html page

  1. #1
    Join Date
    Sep 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Javascript Function execution in html page

    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
    Unix is simple. It just takes a genius to understand its simplicity. – Dennis Ritchie

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Javascript Function execution in html page

    Find appropriate series of HTTP calls doing the reboot and then implement them with Qt using QNetworkAccessManager or QWebPage.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Sep 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Javascript Function execution in html page

    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.
    Unix is simple. It just takes a genius to understand its simplicity. – Dennis Ritchie

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Javascript Function execution in html page

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Sep 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Javascript Function execution in html page

    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
    Unix is simple. It just takes a genius to understand its simplicity. – Dennis Ritchie

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Javascript Function execution in html page

    Quote Originally Posted by saeedIRHA View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Sep 2011
    Posts
    12
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Javascript Function execution in html page

    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
    Unix is simple. It just takes a genius to understand its simplicity. – Dennis Ritchie

Similar Threads

  1. Replies: 1
    Last Post: 30th April 2011, 00:50
  2. getting javaScript from html
    By ashvindh in forum Qt Programming
    Replies: 1
    Last Post: 26th September 2010, 13:57
  3. Replies: 3
    Last Post: 25th February 2010, 09:53
  4. QtWebKit access HTML manipulated by javascript
    By rbp in forum Qt Programming
    Replies: 1
    Last Post: 19th September 2009, 03:29
  5. add custom HTML attribute by javascript in QtWebKit
    By sand.fj.wen in forum Qt Programming
    Replies: 3
    Last Post: 17th April 2009, 08:25

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.