Skip to content
This repository was archived by the owner on Nov 6, 2021. It is now read-only.
This repository was archived by the owner on Nov 6, 2021. It is now read-only.

iframe content doesn't behave like top level: long-press and new-window links #39

@adam-p

Description

@adam-p

injected.js only gets injected in the top-level page, not in iframes. This means that the functionality it provides is not available inside iframes.

So, these are missing (at least):

  • long-press menu: The default/native webview long-press menu is shown, rather than the custom menu. The items on it aren't wired up properly, so they either do nothing or behave oddly.
  • target="_blank" handling: Links with that property will not open in a new tab.

We played with injecting injected.js at every level (top and frames). It fixes the target="blank" problem, but the long-press menu problem remains. This is because when the ObjC function elementsAtLocationFromGestureRecognizer calls the JS function elementsAtPoint, it will only ever call the top-level page's function (because that's how stringByEvaluatingJavaScriptFromString works). So elementsAtPoint would have to do something like: detect that the given coordinates are inside an iframe, change the coordinates to be relative to the frame's location, communicate with the frame (probably via postMessage) to get it to call elementsAtPoint, and then report back to the ObjC. (In addition to the other complications, this will go from being a synchronous call to async.)

You can fool around with the iframe behaviour here:
http://nunzioweb.com/iframes-example.htm (Example 3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions