Comments (8)
Hello @KevinGrandon,
Thanks for kind words. I have implemented the eval for the project but I have not be able to find a time to document it properly. Here the code that does the execution. At the moment you can't load the file and execute it. What you have to do is pass the a valid javascript string into webviewRef.eval()
method.
componentDidMount() {
var webviewRef = this.refs[WEBVIEW_REF];
webviewRef.eval('window.MyInternalVariable=100');
}
let me know if you need more help.
from react-native-webview-bridge.
Hi, thanks for the quick response! I agree that the eval method is useful, but I do think it would be nice to be able to wrap it in a way which could load content from a file on disk (as you might need to execute a large amount of script).
I'm going to play with this to see if I can implement what I am thinking of, and might be able to send you a pull request.
from react-native-webview-bridge.
Agreed, you might want to look into this since WebViewJavascriptBridge
loads WebViewJavascriptBridge.js.txt
as a file and injects it into webview. You might simply add a new method and duplicate the code there and replace it with some file content loader.
from react-native-webview-bridge.
Well, maybe this is not needed. I've found a workaround, and here it is if anyone finds this in the future:
var script = '(' + require('my-script.js').toString() + '());';
webviewRef.eval(script);
from react-native-webview-bridge.
@KevinGrandon - Do you have an example of some script that you were able to execute inside the webview? I'm struggling just get an alert box to show.. I'm using your load & inject script and pointing to a basic test script
<script>
document.addEventListener("DOMContentLoaded", function(event) {
window.alert('injected into site!');
});
</script>
from react-native-webview-bridge.
OK. I worked it out. I didn't need any of the preface, just simply the call to window.alert(). That should enable me to continue. Thanks for this plugin @alinz . Great work :)
from react-native-webview-bridge.
@MossP I have upgraded to 0.3.0. You might want to use this version instead.
from react-native-webview-bridge.
Thanks @alinz, I'll take a look.
from react-native-webview-bridge.
Related Issues (20)
- Super expression error.. HOT 2
- RCTWebViewBridge
- Uncaught TypeError: WebViewBridge.onMessage is not a function
- injectedJavaScript not working on android 5.1 and below
- hi in android it can not run HOT 1
- getting warning
- Accessing View Manager Configs Directly is No Longer Supported
- Rendering HTML file HOT 1
- Question about Browser Version
- Use UIManager.getViewManagerConfig('RCTWebViewBridge') HOT 1
- 'React/RCTViewManager.h' file not found HOT 3
- Not working with react-native 0.6 HOT 3
- onBridgeMessage method not working
- Is this repo officially inactive ? HOT 4
- android app crash while run the app HOT 8
- WebView has been removed HOT 3
- Update to WKWebView for iOS
- Release version 0.40.2 HOT 1
- WebView IOS error HOT 2
- Could not find method compile() for arguments [project ':react-native-webview-bridge'] HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-webview-bridge.