That particular way to access the clipboard is depreciated in most browsers. There’s a newer way you could try. Just google the clipboard JavaScript api. But in general clipboard access doesn’t seem well supported across browsers. No idea what the telegram mini app supports, maybe it has a different way to access the clipboard.
Looking at the error console after running that code could possibly give the error.