Evaluate javascript in external browser in Web_Viewer

I would like to display a modified version of a webpage the user provide, but would be better in the browser he is used to.

I achieved evaluating javascript in webview.
But I wonder if it’s possible to evaluate javascript when “Use external browser” is ON.

First, I thought “no”, but evaluating “alert(“ok”);” works (even if the popup display in app and not in browser).
Other commands (getElementbyId + change color etc) seems not working.

Can this work, or am I wasting my time ?

Thx !

Evaluating js only works with simple things with one line code means you can’t create store and retrieve variable and define function and after that call funtion.
Var a = document.getElementById() Console.log(a)
This didn’t work but
document.getElementById(). innerText works

1 Like

You can wrap a function around your code to work with multi-line statements.

(function(...) {
 //your code here
})(...)
1 Like

Ok, I tested what you said, and a few other things.
I tried what you said and using “When Page loaded” and
document.addEventListener("DOMContentLoaded", () => {var a = document.getElementById("content");alert(a);});
You’re right nothing works.

And if I use WebViewer without the “Use external browser” option, is there same limitations ?

Ok I tested it ! Thank you.
I am going to see if it solves my problem

But i think is not possible to create global variable outside function and during function update this variable nand used in other function.

No.
You can use the WebViewString for that, though

1 Like

Ok, thanks to both of you. I finally got it working, but not using external browser unfortunately. Thx !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.