Results 1 to 4 of 4

Thread: JS not executes in QTWebkit

  1. #1
    Join Date
    Nov 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: JS not executes in QTWebkit

    <html><body>
    <a href="http://google.com" id="alink">link</a>

    <script>
    document.getElementById("alink").click();
    </script>

    When I load a page in QTWebkit with such content, the page doesn't jump to href location "http://google.com". It can jump with mouse click on the label A.

    I think it's the problem of the JS function "click".

    Can anyone help me to solve the problem?

    Regards,
    Eric


    Added after 52 minutes:


    I think it's because QTWebkit not support the JS function click. After add below JS code in html page, it works.
    My problem is how to add the JS in any page automatic for all pages request.

    <script type="text/javascript">
    if(typeof HTMLElement!='undefined'&&!HTMLElement.prototype.c lick)
    HTMLElement.prototype.click=function(){
    var evt = this.ownerDocument.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, this.ownerDocument.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
    this.dispatchEvent(evt); }
    </script>
    Last edited by ericzhang; 18th March 2014 at 08:59.

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

    Default Re: JS not executes in QTWebkit

    You can probably use jQuery for that.
    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
    Nov 2013
    Posts
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: JS not executes in QTWebkit

    Yes, use jQuery can help. The problem is how to change the html content to add jquery to the page when QTWebkit load a frame.

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

    Default Re: JS not executes in QTWebkit

    I think you could just evaluate jQuery script with evaluateJavaScript(). jQuery should then add itself to the document and then you can start calling its functions.
    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.


Similar Threads

  1. Qtwebkit in qt 4.3
    By raj_iv in forum Qt Programming
    Replies: 0
    Last Post: 7th February 2013, 06:49
  2. Replies: 0
    Last Post: 29th February 2012, 09:48
  3. where is QtWebKit.lib?
    By richardander in forum Installation and Deployment
    Replies: 8
    Last Post: 8th April 2009, 16:50
  4. Dialog executes in debug build but not release
    By awhite1159 in forum Qt Programming
    Replies: 5
    Last Post: 24th June 2008, 17:51
  5. Plugin ctor executes, but not dtor ?
    By scollyer in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2008, 14:18

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.