Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. EvaluateJavaScript problem on QML
Qt 6.11 is out! See what's new in the release blog

EvaluateJavaScript problem on QML

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 4.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Adilek
    wrote on last edited by
    #1

    Hi.

    Why this code not works?

    @
    webView.evaluateJavaScript("document.onclick=myfunc;function myfunc(){alert('salam')}")
    @

    The following works well.
    @
    settings.javascriptEnabled is set to true. webView.evaluateJavaScript("alert('salam')")
    @

    1 Reply Last reply
    0
    • A Offline
      A Offline
      apap_
      wrote on last edited by
      #2

      declare your javascript function before calling it :
      @
      webView.evaluateJavaScript("function myfunc(){alert('salam')};document.onclick=myfunc;");
      @

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Adilek
        wrote on last edited by
        #3

        Same problem.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Adilek
          wrote on last edited by
          #4

          I solved. The problem was that I called this function on onUrlChanged event. I put it to onLoadingFinished. Now it works well.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved