Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Catching JavaScript error messages.

Catching JavaScript error messages.

Scheduled Pinned Locked Moved Solved Qt WebKit
javascriptalerterrormessagebox
8 Posts 2 Posters 3.8k Views
  • 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.
  • M Offline
    M Offline
    McLion
    wrote on 12 Jan 2017, 13:47 last edited by McLion 1 Dec 2017, 14:32
    #1

    Hi,

    To catch JavaScript alert message boxes I reimplemented javaScriptAlert(QWebFrame * frame, const QString & msg) to catch alert messages - works as supposed.

    Do I need to reimplement some other function to catch ALL message boxes?
    I need to catch the follwoing message as well that seem to occur from time to time but I can not simulate it here in the lab:
    The script on this page appears to have a problem. Do you want to stop the script.
    The tite of the Message box says JavaScript Problem - IP ....
    Is this covered by reimplementing javaScriptAlert(QWebFrame * frame, const QString & msg)

    I see there a some other like:

    javaScriptConfirm(QWebFrame * frame, const QString & msg)
    javaScriptPrompt(QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result)
    shouldInterruptJavaScript()
    

    Do I need to reimplement these too?

    Thanks
    McL

    K 1 Reply Last reply 12 Jan 2017, 15:47
    0
    • M McLion
      12 Jan 2017, 13:47

      Hi,

      To catch JavaScript alert message boxes I reimplemented javaScriptAlert(QWebFrame * frame, const QString & msg) to catch alert messages - works as supposed.

      Do I need to reimplement some other function to catch ALL message boxes?
      I need to catch the follwoing message as well that seem to occur from time to time but I can not simulate it here in the lab:
      The script on this page appears to have a problem. Do you want to stop the script.
      The tite of the Message box says JavaScript Problem - IP ....
      Is this covered by reimplementing javaScriptAlert(QWebFrame * frame, const QString & msg)

      I see there a some other like:

      javaScriptConfirm(QWebFrame * frame, const QString & msg)
      javaScriptPrompt(QWebFrame * frame, const QString & msg, const QString & defaultValue, QString * result)
      shouldInterruptJavaScript()
      

      Do I need to reimplement these too?

      Thanks
      McL

      K Offline
      K Offline
      Konstantin Tokarev
      wrote on 12 Jan 2017, 15:47 last edited by
      #2

      @McLion Each of listed methods implements its own kind of dialog box, so e.g. to have customized dialogs with your own style you have to implement them all.

      Message box you see now ("The script on this page appears to have a problem....") is provided by default implementation of QWebPage::shouldInterruptJavaScript

      1 Reply Last reply
      1
      • M Offline
        M Offline
        McLion
        wrote on 12 Jan 2017, 15:51 last edited by
        #3

        Konstantin,

        Thanks for the info, specially to which implementation this specific message belongs.
        Need to re-implement them all, I guess.

        Cheers, McL

        1 Reply Last reply
        0
        • M Offline
          M Offline
          McLion
          wrote on 12 Jan 2017, 16:20 last edited by McLion 1 Dec 2017, 16:25
          #4

          Follow up:

          • Any idea how I can simulate this case?
            I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS.
          • Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?
          K 1 Reply Last reply 12 Jan 2017, 16:34
          0
          • M McLion
            12 Jan 2017, 16:20

            Follow up:

            • Any idea how I can simulate this case?
              I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS.
            • Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?
            K Offline
            K Offline
            Konstantin Tokarev
            wrote on 12 Jan 2017, 16:34 last edited by
            #5

            @McLion said in Catching JavaScript error messages.:

            • Any idea how I can simulate this case?
              I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS.

            You don't need any server as QtWebKit can load files from file system or qrc resources. To reproduce just put infinite cycle into some event hanler, e.g. into onclick handler of button

            • Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?

            load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished

            M 1 Reply Last reply 12 Jan 2017, 16:43
            0
            • K Konstantin Tokarev
              12 Jan 2017, 16:34

              @McLion said in Catching JavaScript error messages.:

              • Any idea how I can simulate this case?
                I have a local web server I can use and where I can manipulate existing JS ... problem is I have no clue of JS.

              You don't need any server as QtWebKit can load files from file system or qrc resources. To reproduce just put infinite cycle into some event hanler, e.g. into onclick handler of button

              • Does the webView load() return loadFinished() with a fail or a success after the timeout script has been stopped by returning true in shouldInterruptJavaScript() (stop the JS execution)?

              load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished

              M Offline
              M Offline
              McLion
              wrote on 12 Jan 2017, 16:43 last edited by
              #6

              @Konstantin-Tokarev said in Catching JavaScript error messages.:

              load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished

              OK ... on second thought that's actually clear.
              This means I'll have to take care and initiate a reload for instance.

              Thanks, McL

              K 1 Reply Last reply 12 Jan 2017, 16:52
              0
              • M McLion
                12 Jan 2017, 16:43

                @Konstantin-Tokarev said in Catching JavaScript error messages.:

                load() has nothing to do with JS execution, in fact all JS execution starts after loadFinished

                OK ... on second thought that's actually clear.
                This means I'll have to take care and initiate a reload for instance.

                Thanks, McL

                K Offline
                K Offline
                Konstantin Tokarev
                wrote on 12 Jan 2017, 16:52 last edited by
                #7

                @McLion said in Catching JavaScript error messages.:

                This means I'll have to take care and initiate a reload for instance.

                No need to reload page, you can just stop running script

                M 1 Reply Last reply 13 Jan 2017, 07:56
                0
                • K Konstantin Tokarev
                  12 Jan 2017, 16:52

                  @McLion said in Catching JavaScript error messages.:

                  This means I'll have to take care and initiate a reload for instance.

                  No need to reload page, you can just stop running script

                  M Offline
                  M Offline
                  McLion
                  wrote on 13 Jan 2017, 07:56 last edited by
                  #8

                  @Konstantin-Tokarev
                  For normal web browsing that would be sufficient, yes.
                  In my case we use a web-driven GUI. If I stop the script that needed too long (due to some network error or whatever) the GUI is missing on the device.

                  1 Reply Last reply
                  0

                  1/8

                  12 Jan 2017, 13:47

                  • Login

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