Skip to content
This repository has been 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

Open
adam-p opened this issue Apr 20, 2017 · 0 comments

Comments

@adam-p
Copy link

adam-p commented Apr 20, 2017

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant