RTO_openTab_button.js
Helper file documentation for
RTO_openTab_button.js.Docs updated: 2026-03-24
Summary
Bind buttons to open, navigate, or focus a remote tab, with a lightweight click lock during user actions.
- Exports:
RTObindTabButtons - Depends on: RTO_form_api.js (optional; falls back to postMessage)
- Requires:
window.RTOconnected = true(use RTO_connector.js or your own gate) - Config: optional
window.RTO_PAGE_ORIGIN(must matchcontent.js)
What it is
Binds buttons/links to tab actions using data-rto-* attributes (no custom click handler required).
If the tab is already open and the button is configured for focus, the helper focuses that tab first.
If it needs to open a tab, reusing the same tabKey is now the normal safe path in 7.13.0.
Repeated clicks on the same button are ignored while that user action is still pending, so the page does not spam duplicate requests.
Download
Download RTO_openTab_button.jsConfig
By default, the helper uses origin: "rto-page" for messages.
You can override it globally:
<script>
window.RTO_PAGE_ORIGIN = "my-site"; // must match what content.js checks (msg.origin)
</script>
Data attributes
data-rto-url(required)data-rto-tabKeyordata-rto-key(required)data-rto-when-open:focus|refreshdata-rto-open-focus:1to focus after openingdata-rto-refresh-focus:1to focus after refreshdata-rto-alert-abuse:1to show analert(...)for broad abuse errors such as rate limits or too many pending requestsdata-rto-open-text,data-rto-closed-text: optional label switchingdata-rto-poll: polling interval ms (default 1200)
Example
This button opens the tab the first time, then focuses the same controlled tab on later clicks.
<button
data-rto-url="https://example.com/billing"
data-rto-tabKey="billing"
data-rto-open-focus="1"
data-rto-when-open="focus"
data-rto-alert-abuse="1"
>Open billing</button>
<script>
window.RTO_PAGE_ORIGIN = "my-site";
</script>
<script src="../RTO_helpers/RTO_form_api.js"></script>
<script src="../RTO_helpers/RTO_connector.js"></script>
<script src="../RTO_helpers/RTO_openTab_button.js"></script>
<script>
RTOconnectOnce(1500).then(function(){
RTObindTabButtons();
});
</script>
What this helper does not do
It does not document or rely on older
singleton:true-style patterns.
It also does not claim the tab is “open” before the helper confirms that state through its real tab checks.
User-facing errors
Polling stays quiet on purpose, but click-triggered actions no longer fail silently.
The helper logs useful errors with
console.warn(...).
If you add data-rto-alert-abuse="1", it can also show an alert for broad abuse guards like
RATE_LIMIT_OPEN_TAB, RATE_LIMIT_NAVIGATE, or TOO_MANY_PENDING_REQUESTS.