Ir para conteúdo

POWERED BY:

Arquivado

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

stview

Mostrar barra de rolagem só qnd precisar

Recommended Posts

PeoplessSeguinte, estou trabalhando com iframes(foi necessario) e pintou um problema(pra variar) com a barra de rolagem.Se eu coloco yes, qnd nao precisa ela fica ali opaca, qnd precisa JÓIA.Se eu coloco auto ela não é mostrada, mas come um pedaço da página ...E se coloco no ... nada claro.Tem como eu deixar pra mostrar a barra somente qnd precisa, qnd não precisa ele não comer aquele spaço?

Compartilhar este post


Link para o post
Compartilhar em outros sites

tem sim, mas é um pouco embassadopor exemplo, no windows xp a barra de rolagem é um pouco mais larga do que nas versões anteriores do windows mas.. resolvendo seu problema. você deve basicamente calcular o tamanho (altura) da página e comparar com o tamanho do iframe, se for maior então é porque a barra de rolagem a apareceu.tipo..

You have two properties - document.width and window.innerWidth - by evaluating the difference between those two, you can determine if scrollbars are present. But it gets worse - both the evaluated difference and the width of the scrollbar itself varies between different builds of moz and different OSs.This code finds the true inner width of the window, adjusting for the presence or lack of scrollbars in various builds. It will still only work for users who haven't manually changed their default scrollbar width.var bWidth=window.innerWidth;if(!konqi){if(ns7){sbaa=15;}if(mac&&mz7){sbaa=16;}if(mz7&&agt.indexOf("rc1")!=-1){sbaa=19;}if((mz7&&win&&(agt.indexOf("windows nt 5.1")!=-1))||mac||ns6){if(document.width<=(innerWidth-30)){bWidth-=sbaa;}}else if(mz7&&win&&(agt.indexOf("windows nt 5.0")!=-1)){if(document.width<=(innerWidth-16)){bWidth-=16;}}else if(win){if(document.width<=(innerWidth-17)){bWidth-=17;}}if(lin){if(document.width<=(innerWidth-17)){bWidth-=17;}}To use this you'll also need a sniffer script to create the browser and OS variables:var exclude=true; var agt=navigator.userAgent.toLowerCase();var ie=false; var ie4=false; var ie5=false; var op5=false; var konqi=false;if (typeof document.all!="undefined"&&(agt.indexOf('msie')!=-1)){ie=true; ie4=true; exclude=false;if (agt.indexOf('msie 4')==-1){ie5=true; ie4=false;}if (agt.indexOf('opera')!=-1){ie=false; ie4=false; ie5=false; op5=true;}}var ns6=false; var mz7=false;if (typeof document.getElementById!="undefined"&&!ie){ns6=true; exclude=false;if (agt.indexOf('netscape6')==-1){ns6=false; mz7=true;}if (typeof window.opera!="undefined"){mz7=false; op5=true;}else if (agt.indexOf('gecko')==-1){mz7=false; exclude=true;}}if (agt.indexOf('opera 4')!=-1){op5=false; mz7=false; exclude=true;}var ns4=false;if ((agt.indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=4)&&!ie&&!op5&&!ns6&&!mz7){ns4=true; exclude=false;}if (agt.indexOf('webtv')!=-1){ie=false; ie4=false; exclude=true;}var win=false; var mac=false; var lin=false;if (agt.indexOf('win')!=-1){win=true; mac=false; lin=false;}else if (agt.indexOf('mac')!=-1){win=false; mac=true; lin=false;}else{win=false; mac=false; lin=true;}if (typeof navigator.vendor!="undefined"){if (navigator.vendor =="KDE"){ie=false;ie4=false;ie5=false;konqi = true;ns6=true;ns4 = false;exclude = false;var thisKDE=agt;var splitKDE=thisKDE.split("konqueror/");var aKDE=splitKDE[1].split("; ");var KDEn=parseFloat(aKDE[0]);var oldKde=false;if(KDEn<2.2){oldKde=true;exclude=true;ns6=false;konqi=false;}}}var op6=false;if((agt.indexOf("opera 6")!=-1)||(agt.indexOf("opera/6")!=-1)){op6=true;op5=false;}var ie6=false;if(ie5&&agt.indexOf("msie 6")!=-1){ie6=true;}var dcm = document.compatMode;var com=false;if(ie6&&dcm!="BackCompat"){com=true;}var ice=false;if(typeof navigator.__ice_version!="undefined"){ice=true; ie=false; ie5=false; ie4=true; ns4=false;}var ns7=false;if(agt.indexOf("netscape/7")!=-1){mz7=false; ns6=true; ns7=true;}

fonte: http://www.codingforums.com/archive/index.php/t-3486

Compartilhar este post


Link para o post
Compartilhar em outros sites

Meu que code loko e bagunçado ...Não testei ainda mas ja vi que ele é pra barra horizontal, vou ter que cuidar pra mudar tudo direitinho.Depois posto se funcionar.Se alguem tiver um code mais simples ta valendo...

Compartilhar este post


Link para o post
Compartilhar em outros sites

Meu que code loko e bagunçado ...Não testei ainda mas ja vi que ele é pra barra horizontal, vou ter que cuidar pra mudar tudo direitinho.Depois posto se funcionar.Se alguem tiver um code mais simples ta valendo...

porque quando se faz esse tipo de aplicação você deve pensar sempre que deve funcionar em qualquer browser e qualquer sistema operacionala não ser que você queira fazer algo limitado, apenas pra um 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.