Notalib / nativescript-webview-ext

Nativescript plugin with extended WebView functionality
Apache License 2.0
76 stars 37 forks source link

How to reset autoLoadJavascriptFile() - Android #74

Closed erjdriver closed 4 years ago

erjdriver commented 4 years ago

For a WebViewExt - I've set autoLoadJavascriptFile().

Sometimes - in the middle of the session the Javascript code can change - if I call autoLoad again - 2 copies of the code (old and new get loaded).

How can I - delete/replace previous autoload file?

I hope the file contents are not cached somewhere - because I change the contents of the same file and would like the new contents to be injected in subsequent page loads. I tried the following before the 2nd call to autoLoad - but didn't work

this.webview.unregisterLocalResource( "js_code");

m-abs commented 4 years ago

You should be able to reset it with removeAutoLoadJavaScriptFile("js_code")

erjdriver commented 4 years ago

My apologies.

I did look up on your main doc page and that method wasn't there.

This method almost solves the issue...

It happens only once after I remove and set the autoload file AND also second download session and after.

I think the reason for that is that webview already has a file loaded when I try the remove/set after the first time.

When I start my next session - the webview has my last webpage and already has my jscode injected.

The new remove/set - causes another copy and the error message.

Does this make sense?

It's not an issue for me because I don't plan to use the last page immediately.

But down the road - someone else might want to work with the existing page.

Maybe autoload shouldn't load on the current page?

Don't know what the right way would be - thanks.

erjdriver commented 4 years ago

Issue closed.