2

I'd like to be able to inject a JavaScript call into a WebView within React-Native in order to be able to modify the view it is displaying. For example, I'd like to inject:

 setRouteId(125123123);

and have it execute against the current context. Is there a way to do this with React-Native's WebView? I don't see anything currently in the source code but wanted to make sure I am not missing anything.

1
  • I don't believe that it exists after a lot of investigation of the source code. I put together a pull request to add support for stringByEvaluatingJavaScriptFromString in a pull request: github.com/facebook/react-native/pull/1191/files Commented May 7, 2015 at 20:26

1 Answer 1

2

As long as you have control over the javascript you want to invoke, you can change the hash context of a url without the webview reloading. So if you set the webview url to append #route-id=125123123 to the current url, listening in JS for the onhashchange event will let you perform the action.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.