Skip to content

Instantly share code, notes, and snippets.

@ali-master
Last active December 27, 2016 00:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ali-master/ed513d4f61a881c89613969264aeebb7 to your computer and use it in GitHub Desktop.
Save ali-master/ed513d4f61a881c89613969264aeebb7 to your computer and use it in GitHub Desktop.
Lunch telegram link with installed Telegram application

Lunch telegram link with installed Telegram application

var protoUrl = "tg:\/\/resolve?domain=TelegramUserName";
if (false) {
    var iframeContEl = document.getElementById('telegramIframe') || document.body;
    var iframeEl = document.createElement('iframe');
    iframeContEl.appendChild(iframeEl);
    var pageHidden = false;
    window.addEventListener('pagehide', function () {
        pageHidden = true;
    }, false);
    window.addEventListener('blur', function () {
        pageHidden = true;
    }, false);
    if (iframeEl !== null) {
        iframeEl.src = protoUrl;
    }
    setTimeout(function() {
        if (!pageHidden) {
            window.location = protoUrl;
        }
    }, 2000);
}else if (protoUrl) {
    setTimeout(function() {
        window.location = protoUrl;
    }, 100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment