function delegateNewWindowsToFront(): void;
Calling this function will add an event listener on the window
object to delegate opening some links with Front. It will automatically call Front.openUrl
if one of the following conditions is true:
- The link opens a new window (
target
property of the anchor is set to_blank
) - The link is to compose an email (
href
property of the anchor starts withmailto:
) - The link is opened with
window.open
and the target is_blank
or empty:window.open(url, "_blank")
orwindow.open(url)
The goal of this function is to make it easier to have links compatible with Front. Its usage is totally opt-in and you can always stop the propagation of the click event to prevent triggering the listener.
import {delegateNewWindowsToFront} from '@frontapp/plugin-bridge';
delegateNewWindowsToFront();
If you need to use this function in global installations
When including the Plugin SDK as a global library, you can use an attribute to have this behavior run automatically, as shown in the code below. Note that this is not the recommended method of installing the Plugin SDK.
<html>
<head>
<script
type="text/javascript"
src="//dl.frontapp.com/libs/plugin-sdk-1.8.0.min.js"
delegateNewWindowsToFront
></script>
</head>
<body>
<script type="text/javascript">
// delegateNewWindowsToFront() will be called automatically
</script>
</body>
</html>