[WebView] Is it possible to load local js file in WebView html prop?
See original GitHub issueFor Example, I put a web/jquery.js file in bundle, then I would like to use:
var html=`
<html>
<script src="web/jquery.js"></script>
...`;
then use WebView to set html prop to html.
I tried to set src to jquery in CDN, it works fine. but don’t work with above code.
Is it because currently local js in WebView not be supported? Or I miss something at here?
Issue Analytics
- State:
- Created 8 years ago
- Comments:26 (3 by maintainers)
Top Results From Across the Web
Android webview load local javascript - Stack Overflow
I am trying to load a javascript file stored on the device via html file which is loaded via a webview but never...
Read more >Loading in-app content - Android Developers
WebViewAssetLoader is a flexible and performant way to load in-app content ... Text files like HTML, JavaScript, and CSS belong in assets.
Read more >WebView - React Native
WebView renders web content in a native view. ... in the WebView . Can be a local or remote file. method (string) -...
Read more >How to use Webview in React Native? - The Wirescript
Here's how you can use WebView inside React Native to display websites or entire web apps natively inside your application.
Read more >Xamarin.Forms WebView - Microsoft Learn
HTML & CSS websites – WebView has full support for websites written using HTML & CSS, including JavaScript support. Documents – Because WebView...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

If I package my app and view it on an iOS device, the asset files are not there. The only file, that is there, is the html file used by the WebView (and required). How can I make sure, the packager copies the *.js and *.css files to the asset directory?
@bright-sea - the second option I proposed would help:
<WebView baseURL="/web" html={html} />By setting the baseURL, like in the example I linked to on StackOverflow, the WebView knows where to look for the css/js that you link to 😄
The
htmlvar I’m using there is just the same as what you used in your original post.