Ir para conteúdo
Fórum Script Brasil
  • 0

(Resolvido) Valor e inserir no link


victormartins

Pergunta

Eae pessoal!

Não manjo muito de Javascript.. então vim pedir ajuda ^^

<script LANGUAGE="JavaScript">

function qlimit () {

if ((screen.width == 640) && (screen.height == 480)){

qlimit = 2;

}

else if ((screen.width == 800) && (screen.height == 600)){

qlimit = 3;

}

else if ((screen.width == 1024) && (screen.height == 768)){

qlimit = 4;

}

else if ((screen.width == 1280) && (screen.height == 800)){

qlimit = 15;

}

else {

qlimit = 10;

}

}

//-->

</script>

Ele ve a resolução e dar um valor que será inserido no link:

<iframe src='ult.php?qlimit='+qlimit+'' width='615' height='155' frameborder='no'></iframe>");

Ele da o valor lá no "qlimit" e deveria inserir na URL na QS "qlimit".

Acho que está errado o código :P

Se alguém puder dar um help ^^

Agradeço desde já!

[]'s

Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

você coloca dentro de uma tag html sem abrir nada javascript, logo a pagina não vai entender +qlimit+, faça o seguinte:

<script LANGUAGE="JavaScript">
function qlimit () {
if ((screen.width == 640) && (screen.height == 480)){
qlimit = 2;
}
else if ((screen.width == 800) && (screen.height == 600)){
qlimit = 3;
}
else if ((screen.width == 1024) && (screen.height == 768)){
qlimit = 4;
}
else if ((screen.width == 1280) && (screen.height == 800)){
qlimit = 15;
}
else {
qlimit = 10;
}
document.getElmentById("iframe").src = 'ult.php?qlimit=' + qlimit;
}
//-->
</script>

<iframe id="iframe" width='615' height='155' frameborder='no'></iframe>");

Link para o comentário
Compartilhar em outros sites

  • 0

Estranho... não funcionou...

<script LANGUAGE="JavaScript">
function qlimit () {
if ((screen.width == 640) && (screen.height == 480)){
qlimit = 2;
}
else if ((screen.width == 800) && (screen.height == 600)){
qlimit = 3;
}
else if ((screen.width == 1024) && (screen.height == 768)){
qlimit = 4;
}
else if ((screen.width == 1280) && (screen.height == 800)){
qlimit = 15;
}
else {
qlimit = 10;
}
window.onload = function() {
  qlimit ();
};
document.getElmentById("iframe").src = 'ult.php?qlimit=' + qlimit;
}

//-->
</script>
<iframe id="iframe" width='615' height='155' frameborder='no'></iframe>
Até tentei fazer isto:
<script LANGUAGE="JavaScript">
function qlimit () {
if ((screen.width == 640) && (screen.height == 480)){
qlimit = 2;
}
else if ((screen.width == 800) && (screen.height == 600)){
qlimit = 3;
}
else if ((screen.width == 1024) && (screen.height == 768)){
qlimit = 4;
}
else if ((screen.width == 1280) && (screen.height == 800)){
qlimit = 15;
}
else {
qlimit = 10;
}
window.onload = function() {
  qlimit ();
}

}

//-->
</script>

 <script>
document.write("<iframe src='ult.php?qlimit='+qlimit' width=615 height=155 frameborder=no></iframe>");
            </script>

Editado por victormartins
Link para o comentário
Compartilhar em outros sites

  • 0

Use o debug do iE ou FF para vizualizar as possíveis falhas....fica mais fácil, quando fala que não funcionou fica muito vago para gente...

No primeiro código pelo menos deu pra notar que usou a chamada getElementById errado, além de estar sobrando uma aspas simples. Só consertar...

Olha só:

<iframe id="iframe" width="615" height="155" frameborder="no"></iframe>
<script type="text/javascript">

function qlimit(){
 with(screen)
     switch(width){
          case 640:
              if(height==480)
              return 2; break
          case 800:
              if(height==600)
              return 3; break
          case 1024:
              if(height==768)
              return 4; break
          case 1280:
              if(height==800)
              return 15; break
          default: return 10
     }
}
window.onload=function(){
 document.getElementById('iframe').src="ult.php?qlimit=" + qlimit()
}
</script>

Só usei umas frescuras a mais, mas funciona igualmente ao exemplo dado pela Andreia e pelo Allan.

Aquele abraço

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      652k
×
×
  • Criar Novo...