Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Qt 4.8.4 QtWebkit doesn't load Javascript

Qt 4.8.4 QtWebkit doesn't load Javascript

Scheduled Pinned Locked Moved Mobile and Embedded
4 Posts 2 Posters 3.4k 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
    adrian
    wrote on last edited by
    #1

    Hello,

    I'm using qtwebkit to load webpage inside my app. The HTML is loaded well but the Javascript is never loaded.

    Do you know what could be happen ?

    Thanks a lot.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      please make sure:
      @
      myWebView->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
      @

      If it still doesn't work subclass QWebPage and reimplement javaScriptConsoleMessage():
      @
      void MyWebPage::javaScriptConsoleMessage ( const QString & message, int lineNumber, const QString & sourceID )
      {
      qDebug() << "CONSOLE (" << sourceId << ":" << lineNumber << "):" << message;
      }
      @
      Then you can see any javascript error which prevent your script to be loaded.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

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

        Thank you for your response.

        I've ensure that I've enabled the javascript attribute.
        When I execute "evaluateJavascript('console.log('test')'), the javascript engine does not return any result to invoke MyWebPage::javaScriptConsoleMessage function.
        I think the problem is into the WebKit Javascript engine, I am enabling the javascript attribute but it is not enabling it.
        I have tried to test a simple web page executing an alert('') function, and if I execute into a desktop envioment (linux X86) it works correctly. If I build the same code into a ARM enviroment, it not works. Any idea?

        Thank you.

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

          Hello,

            I have tried to execute this function:
          

          QVariant name = ui->myBrowser->page()->mainFrame()->evaluateJavaScript("function abc(){alert('This page has finished loading!');return 'he'} abc();");

          qDebug() << "NAME: " << name.toString();

          The result of NAME can be garbage of the buffer?

            NAME:  "-1.45215999014136e-58"       NAME:  "-1.45215999014147e-58"       NAME:  "-1.45215999014158e-58"       NAME:  "-1.45215999014169e-58"       NAME:  "-1.45215999014179e-58"       NAME:  "-1.4521599901419e-58"       NAME:  "-1.45215999014201e-58"       NAME:  "-1.45215999014212e-58"       NAME:  "-1.45215999014222e-58"       NAME:  "-1.45215999014233e-58"       NAME:  "-1.45215999014244e-58"       NAME:  "-1.45215999014255e-58"       NAME:  "-1.45215999014265e-58" 
          

          I am using QT 4.8.4 version, and with older versions I had not problems.

          Thanks.

          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