Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Stevan Danielli Costa

Código JS

Recommended Posts

Bom, primeiramente boa tarde galera e desculpa se to postando no local errado, é meu primeiro post aqui.

 

Bom to com um probleminha aqui numa função que peguei se não me engano aqui mesmo.

To usando ela pra pegar a altura total da tag BODY, ela ta funcionando bem certo no FIREFOX, GOOGLE CHROME, SAFARI... mas não ta funcionando no meu querido Internet Explorer (--') e nem no Opera também, intão galera se alguem souber como eu ajeito ou se tem outra função pra faze a mesma coisa. Agradeço desde já.

 

function getPageSize(){
var xScroll, yScroll;
var windowWidth, windowHeight;

if (window.innerHeight && window.scrollMaxY) {
	xScroll = document.body.scrollWidth;
	yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
	xScroll = document.body.scrollWidth;
	yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
	xScroll = document.body.offsetWidth;
	yScroll = document.body.offsetHeight;
}
if (self.innerHeight) {	// all except Explorer
	windowWidth = self.innerWidth;
	windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	windowWidth = document.documentElement.clientWidth;
	windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
	windowWidth = document.body.clientWidth;
	windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
	pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
return pageHeight;
}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Tenta esse codigo

function getDocHeight() {
   var D = document;
   return Math.max(
       Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
       Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
       Math.max(D.body.clientHeight, D.documentElement.clientHeight)
   );
}

 

Obs: nao testei no IE pois estou usando Linux nesse momento, mas segundo o autor do codigo, eh totalmente crossbrowser http://james.padolsey.com/javascript/get-document-height-cross-browser/

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.