Search code examples
javascripthtmltelegram

How to expand the telegram web application to the top using window.Telegram.WebApp.expand(); in html


How to expand the telegram web application to the top using window.Telegram.WebApp.expand(); in html , here is an example of my code, but nothing works

<html>
<head>
    
    <script>
    window.Telegram.WebApp.ready();
    window.Telegram.WebApp.expand();
    </script>
    
    
</head>

I don't know if I'm using window.Telegram incorrectly.WebApp.expand(); I'm just a beginner


Solution

  • Have you imported the WebApp script?

    <script src="https://telegram.org/js/telegram-web-app.js"></script>
    

    if yes try this way

    <script>
        window.Telegram.WebApp.ready(function() {
            window.Telegram.WebApp.expand();
        });
    </script>