question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[WebView] Is it possible to load local js file in WebView html prop?

See original GitHub issue

For 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:closed
  • Created 8 years ago
  • Comments:26 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
richardbrammercommented, Mar 5, 2016

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?

7reactions
brentvatnecommented, May 29, 2015

@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 html var I’m using there is just the same as what you used in your original post.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found