Results 1 to 2 of 2

Thread: QWebView evaluateJavaScript don't work with anchor which href is javascript

  1. #1
    Join Date
    Jan 2013
    Posts
    7
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question QWebView evaluateJavaScript don't work with anchor which href is javascript

    Now i open a URL by QWebView in my PyQt code, then i want to trigger a click on an anchor, the anchor code is below:
    Qt Code:
    1. <a class="btn-bid" href="javascript:;" id="exchange-btn" data-sk="exchange">exchange</a>
    To copy to clipboard, switch view to plain text mode 
    and this is my code below:
    Qt Code:
    1. code = """
    2. document.getElementById("exchange-btn").click()
    3. """
    4. self.view.page().mainFrame().evaluateJavaScript(code)
    To copy to clipboard, switch view to plain text mode 
    but is did not work for me.
    I try the code :document.getElementById("exchange-btn").click() in Firefox and one other browser console(by F12), the code works fine.

    There is some error in my code or something missing? My Qt version is 4.8.6 and we can not use jquery in this webpage.
    Is there someone can tell me how to solve this problem??

  2. #2
    Join Date
    Jan 2013
    Posts
    7
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QWebView evaluateJavaScript don't work with anchor which href is javascript

    For some reason, when using findFirstElement of QWebFrame, the isNull() function of return QWebElement return True. so i change to find his parent element and it works. then i run javascript use same line, and it works fine.
    good luck for you.

Similar Threads

  1. QWebView and evaluateJavaScript
    By hereiam in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2013, 12:18
  2. Replies: 1
    Last Post: 11th May 2012, 18:08
  3. Strange QWebView href border
    By alexandersv in forum Qt Programming
    Replies: 0
    Last Post: 21st July 2011, 04:13
  4. QWebView and scrolling to anchor
    By serenti in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2009, 16:55

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.