Reputation: 81
I am developing a website. The problem is that when opening the website link from the mobile Telegram app, it opens in the app's built-in browser. This browser has its own limitations that are causing problems for me. How can I make the links open in the phone's default browser instead?
adding ?target=_blank
at the end of url didn't fix this problem
also try add this script in index.html
<script>
console.log("start")
if (navigator.userAgent.indexOf("Telegram") != -1) {
console.log("navigator.userAgent.indexOf('Telegram') != -1")
window.location.replace("https://traffic-simulation.ru");
console.log("window.location.replace('https://traffic-simulation.ru');")
}
</script>
.htaccess
file. It didn't help meso how can I make a website link open NOT in the Telegram app's built-in browser?
Upvotes: 8
Views: 4454
Reputation: 63
This works:
if (window.TelegramWebview) {
const url = window.location.href;
const chromeUrl = `intent://${url.replace(/^https?:\/\//, '')}#Intent;scheme=https;end`;
window.location.href = chromeUrl;
}
Upvotes: 0
Reputation: 21
<script src="https://telegram.org/js/telegram-web-app.js"></script> <button onclick="javascript:Telegram.WebApp.openLink('https://www.google.com/');">Click Me</button>
How I did it with a button.
https://github.com/telegram-mini-apps-dev/vanilla-js-boilerplate/tree/master
Upvotes: 1