Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to detect user pressing on link inside the book #98

Open
dudihisine opened this issue Dec 6, 2017 · 2 comments
Open

How to detect user pressing on link inside the book #98

dudihisine opened this issue Dec 6, 2017 · 2 comments

Comments

@dudihisine
Copy link

dudihisine commented Dec 6, 2017

Hey,

I'm using readium and every thing is working just fine!
What i need to do is to detect a user press on a link that opens the safari something like:
"Click here to see more books" - opens new safari page with that link
After i detects it i need to make a change to the url and after that open it with the changes.

What should i do?

Update:

Several books contains hyper link and what i want to do is to replace the link with custom link of my own.

I manage to get the page content and replace the link, but when i load the webView with the new content i cant go back or to the next page because the html is not reader.html anymore and it not response to the JS commands of Readium.

I already tried to recognise the navigationType but what i get is pageDidChange and it recognise it as UIWebViewNavigationTypeOther so it didn't work.

So the only way I can think of, is to replace the current file with my configured file but the file path is http://127.0.0.1:port/file.xhtml. and i didn't figure out a way to replace file in that kind of path

Hope you can help me with this.

@danielweck
Copy link
Member

danielweck commented Jan 25, 2018

Absolute HTTP hyperlinks in EPUB HTML content documents are processed specifically by readium-shared-js, see window.open(href, '_blank') here:
https://github.com/readium/readium-shared-js/blob/dd645d38f8c29e01b386cd2b2864379358e91ed6/js/views/internal_links_support.js#L210

You should be able to capture / intercept this "_BLANK" navigation request from the native webview API.

@egvroom
Copy link

egvroom commented Nov 28, 2018

You could do something like this:

  • Use the WKUIDelegate like so -> webView.UIDelegate = self
  • In (WKWebView *)webView:(WKWebView *)webView createWebViewWithConfiguration:(WKWebViewConfiguration *)configuration forNavigationAction:(WKNavigationAction *)navigationAction windowFeatures:(WKWindowFeatures *)windowFeatures
    you can use navigationAction.request.URL.absoluteString to get the URL being called, and just change it, if you need.

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

No branches or pull requests

4 participants