Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-13512

WebView has no way of jumping to an anchor

    XMLWordPrintable

Details

    Description

      I have a WebView embedded inside a Flickable, and I'm trying to move the
      page appropriately when a user clicks on a link that's an anchor to the
      same page, such as:

      <a href="#references">Jump to References</a>

      I looked at the source code in demos/declarative/webbrowser, but I fear
      that they may have forgotten about the use of links for that purpose,
      since the code in FlickableWebView looks like:

      (...)
      onUrlChanged: {
      // got to topleft
      flickable.contentX = 0
      flickable.contentY = 0
      if (url != null)

      { header.editUrl = url.toString(); }

      }
      (...)

      contentY shouldn't typically be set to 0 if the url changes just by the
      anchor part (i.e. from http://www.example.com#section1 to
      http://www.example.com#section2). My question is: Does the QML WebView
      element exposes enough of its state in its API so that we can actually
      scroll to the right place on the page ? If not, shouldn't we submit a
      bug report or feature request ?

      Example:
      Use the demos/declarative/webbrowser QML example and visit
      http://en.wikipedia.org/wiki/Uniform_Resource_Locator
      ... and try any of the "Contents" link: Instead of scrolling to the
      right place on the page, it will go back to the top of the document.

      Attachments

        1. webviewanchor.diff
          4 kB
          Martin Jones (closed Nokia identity)

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              shausman Simon Hausmann
              martjone Martin Jones (closed Nokia identity) (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes