Fiqh-us-Sunnah Volume 2, Supererogatory Prayer, Fiqh 2.130A.
Section : Feeling drowsy while in the mosque.
It is preferred for one who is in the mosque to change place if he feels sleepy. The movement may remove some of his drowsiness and help wake him up. This rule is true for Fridays and any other day.
Ibn ‘Umar reports that the Prophet sallallahu alehi wasallam said: “If one of you becomes sleepy while he is in the mosque, he should move from his place to another place.” This is related by Ahmad, Abu Dawud, al-Baihaqi, and at-Tirmizhi who calls it hasan sahih.