Skip to content

Instantly share code, notes, and snippets.

@pedroraft
Created November 28, 2022 17:58
Show Gist options
  • Save pedroraft/a4d018ef6b885aebded8ff6487d6925e to your computer and use it in GitHub Desktop.
Save pedroraft/a4d018ef6b885aebded8ff6487d6925e to your computer and use it in GitHub Desktop.
window.openToky = function openToky(number) {
const title = 'Toky';
const w=300;
const h=500;
const _options = 'scrollbars=no,resizable=no';
const url = 'https://app.toky.co/business/dialer#?call='+number;
// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.scareenLeft != undefined ? window.screenLeft : screen.left;
const dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
const _left = ((width / 2) - (w / 2)) + dualScreenLeft;
const _top = ((height / 2) - (h / 2)) + dualScreenTop;
const newWindow = window.open(url, title, _options +', width=' + w + ', height=' + h + ', top=' + _top + ', left=' + _left);
// Puts focus on the newWindow
if (window.focus) newWindow.focus();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment