← Javascript

Largura da Janela

Lida 4193 vezes

Offline

nram 
Membro
Mensagens 777 Gostos 0
Feedback +1

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Boas,
Gostaria de saber se existe maneira de descobrir a largura actual da janela aberta, em JS claro.

cumps
Offline

Pedro Lopes 
Beta tester
Mensagens 3568 Gostos 18
Feedback +6

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Windows User Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3

Código: [Seleccione]
<script>
   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         winW = window.innerWidth;
         winH = window.innerHeight;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         winW = document.body.offsetWidth;
         winH = document.body.offsetHeight;
      }
   }
   document.write(winW+"x"+winH);
</script>
Offline

nram 
Membro
Mensagens 777 Gostos 0
Feedback +1

Troféus totais: 28
Trófeus: (Ver todos)
Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Código: [Seleccione]
<script>
   if (parseInt(navigator.appVersion)>3) {
      if (navigator.appName=="Netscape") {
         winW = window.innerWidth;
         winH = window.innerHeight;
      }
      if (navigator.appName.indexOf("Microsoft")!=-1) {
         winW = document.body.offsetWidth;
         winH = document.body.offsetHeight;
      }
   }
   document.write(winW+"x"+winH);
</script>

Obrigado!