Close app from webviewer

hi, do you know how to close app from a link inside webviewer? I have the close butto inside webpage… and this button should close the app… i cannot find a way :slight_smile:any help?

Hello, you have the exact same topic here on the AI2 forum, why are you creating duplicate topics?

Also, if you want help, please show your blocks and explain more about the

Yoshi

1 Like

The easiest way I suggest is the following:

Create an event listener on the element by JavaScript and log a number on the button click.

Then in Kodular, use this block -
image

and program it in the following way -

when WebViewer.onConsoleMessage
if get_message == <the number you logged >
then
close application

I hope that will solve your problem.

1 Like

hi,
i tested by adding in my webpage the following script:
script

and into the app the following block (just to test if works i used a label text content)
but no result: the label is empty

blocks (4)

no result :frowning:

blocks (5)

Sorry, because Exit button is not having any url. :sweat_smile:

Edit : If you want to close app by clicking any button that contain a link, you can then use cirrent URL to close app.

Btw, the block you posted, it not what I said! You made mistake!

sorry, don’t understand…
starting from the answer of @catastrophe2help it seems to be feasible but the problem is that i’m not able to read the console.log variable set on my webpage…

You can trie with clock and variable with link to go out.
On clock > condition if Webviewer Current URL = Variable > Close App

:sweat_smile: But if the button on website is a Exit button itself, then there will be no URL.

Yes, but button go to another link and with clock detect it ang go out !! :wink:

i would like to avoid clock. if i use clock maybe the app can strong the cpu of the device?

Yes, if the button is having a Link, then he can use this method.
Btw, clock component is not required.

So how you can control to close the app ??

You can post what your button are in web ?

If Webviewer current URL = www.example.com/exit, then Close app.

1 Like

Yes you right but need to be load and this take time. With clock set to 250 close more fast :grinning:

so all these suggestions avoid the usage of @catastrophe2help

You can’t start clock before getting current URL! So, clock wouldn’t going to make it faster!

No, I’m not avoiding! Actually we all are suggesting you same method!

sorry, i’m going in a bit in confusion… can you show me an example that i can replicate? (sorry friend)