Webview Lifecycle

There are different Java Script Methods that you can add to your HTML, which will automatically be called during the life time of the webview:

<html>
<head>
<script>

/* This is called after the webview content has loaded*/
function BTTInitialize() {

}

/* This is called before the webview exits and destroys its content*/
function BTTWillCloseWindow() {

}

/* This is called before the webview hides*/
function BTTWillHideWindow() {

}

/* This is called when the webview becomes visible*/
function BTTWindowWillBecomeVisible() {

}

/* This is called when a script variable in BTT changes. */
async function BTTNotification(note) {
   let data = JSON.parse(note);
   console.log(data.note, data.name);


   // example to get the currently active app, this works for any BTT variable you define:
   if(data.note == "BTTVariableChanged" && data.name == 'BTTActiveAppBundleIdentifier') {
      // the notification does only contain the name of the changed variable, so you'll need to retrieve
      // the value yourself:
      let bundleIdentifier = await get_string_variable({variable_name: 'BTTActiveAppBundleIdentifier'});
      console.log(data.note, data.name, bundleIdentifier);
   }

}

</script>
</head>
<body>
</body>
</html>

results matching ""

    No results matching ""