Jump to content


Photo

Não Sei Como Dizer...


  • Faça o login para participar
4 replies to this topic

#1 Without a Nick

Without a Nick

    Sem culpa no cartório

  • Usuários
  • 2378 posts
  • Sexo:Não informado
  • Localidade:Guarulhos

Posted 27/09/2003, 16:16

Olha, gente!

Tenho um script que recupera o valor de uma querystring. Então, eu tenho uma página com dois frames, um em cima e outro embaixo. Quero que a página(parceria.cfm?id=Número do id) seja redirecionado para o frame debaixo.

Olha:

Se o id for 120, então o frame debaixo vai ser redirecionado para a página http://www.pagina.com.br


Como faço isso?


WITHOUT A NICK

#2 Without a Nick

Without a Nick

    Sem culpa no cartório

  • Usuários
  • 2378 posts
  • Sexo:Não informado
  • Localidade:Guarulhos

Posted 27/09/2003, 18:56

Olhem os códigos:

parceria.cfm
<html>

<head>
<script src=scripts/querystring.js></script>
<script>
<!--
var id=Request.QueryString("id");
var done=0;
parent.frames[principal].location=id;
//-->
</script>
<title>Parceria</title>

</head>
<frameset rows="88,*" framespacing="0" border="0" frameborder="0">
  <frame name="cabecalho" scrolling="no" noresize target="principal" src="parceria/up.html">
  <frame name="principal" src="parceria/down.html" scrolling="auto">
</frameset>


</html>


querystring.js
function RObj(ea) {
var LS="";var QS=new Object();var un="undefined";var f="function";var n="number";var r="string";var e1="ERROR: Index out of range in\r\nRequest.QueryString";var e2="ERROR: Wrong number of arguments or invalid property assignment\r\nRequest.QueryString";var e3="ERROR: Object doesn't support this property or method\r\nRequest.QueryString.Key"
function Err(arg) {if (ea) alert("Request Object:\r\n"+arg)}
function URID(t) {var d="";if (t) {for (var i=0; i<t.length; ++i) {var c=t.charAt(i);d+=(c=="+" ? " ":c);};};return unescape(d);}
function OL(o) {var l=0;for (var i in o) {if (typeof(o[i])!=f) l++;};return l;}
function AK(key) {var auk=true;for (var u in QS) {if (typeof(QS[u])!=f && u.toString().toLowerCase()==key.toLowerCase()) {auk=false;return u;}};if (auk) {QS[key]=new Object();QS[key].toString=function() {return TS(QS[key])};QS[key].Count=function() {return OL(QS[key])};QS[key].Count.toString=function() {return OL(QS[key]).toString()};QS[key].Item=function(e) {if (typeof(e)==un) return QS[key];else {if (typeof(e)==n) {var a=QS[key][Math.ceil(e)];if (typeof(a)==un) Err(e1 +"(\""+key+"\").Item("+e+")");return a;}else Err("ERROR: Expecting numeric input in\r\nRequest.QueryString(\""+key+"\").Item(\""+e+"\")");}};QS[key].Item.toString=function(e) {if (typeof(e)==un) return QS[key].toString();else {var a=QS[key][e];if (typeof(a)==un) Err(e1+"(\""+key+"\").Item("+e+")");return a.toString();};};QS[key].Key=function(e) {var t=typeof(e);if (t==r) {var a=QS[key][e];return (typeof(a)!=un && a && a.toString() ? e:"");}else Err(e3+"("+(e?e:"")+")");};QS[key].Key.toString=function() {return un};};return key}
function AVTK(key, val) {if (key!="") {var key=AK(key);var l=OL(QS[key]);QS[key][l+1]=val;}}
function TS(o) {var s="";for (var i in o) {var ty=typeof(o[i]);if (ty=="object") s+=TS(o[i]);else if (ty!=f) s+=o[i]+", ";};var l=s.length;if (l>1) return(s.substring(0,l-2));return (s=="" ? un:s);}
function KM(k, o) {var k=k.toLowerCase();for (var u in o) {if (typeof(o[u])!=f && u.toString().toLowerCase()==k) return u;};}
if (window.location && window.location.search) {LS=window.location.search;var l=LS.length;if (l>0) {LS=LS.substring(1,l);var preAmpAt=0;var ampAt=-1;var eqAt=-1;var k=0;var skip=false;for (var i=0; i<l; ++i) {var c=LS.charAt(i);if (LS.charAt(preAmpAt)=="=" || (preAmpAt==0 && i==0 && c=="=")) skip=true;if (c=="=" && eqAt==-1 && !skip) eqAt=i;if (c=="&" && ampAt==-1) {if (eqAt!=-1) ampAt=i;if (skip) preAmpAt=i+1;skip=false;};if (ampAt>eqAt) {AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,ampAt)));preAmpAt=ampAt+1;eqAt=ampAt=-1;++k;};};if (LS.charAt(preAmpAt)!="=" && (preAmpAt!=0 || i!=0 || c!="=")) {if (preAmpAt!=l) {if (eqAt!=-1) AVTK(URID(LS.substring(preAmpAt,eqAt)),URID(LS.substring(eqAt+1,l)));else if (preAmpAt!=l-1) AVTK(URID(LS.substring(preAmpAt,l)),"");};if (l==1) AVTK(LS.substring(0,1),"");};};};var TC=OL(QS);if (!TC) TC=0
QS.toString=function() {return LS.toString()};QS.Count=function() {return (TC ? TC:0)};QS.Count.toString=function() {return (TC ? TC.toString():"0")};QS.Item=function(e) {if (typeof(e)==un) return LS;else {if (typeof(e)==n) {var e=Math.ceil(e);var c=0;for (var i in QS) {if (typeof(QS[i])!=f && ++c==e) return QS[i];};Err(e1+"().Item("+e+")");}else return QS[KM(e, QS)];};return un;};QS.Item.toString=function() {return LS.toString()};QS.Key=function(e) {var t=typeof(e);if (t==n) {var e=Math.ceil(e);var c=0;for (var i in QS) {if (typeof(QS[i])!=f && ++c==e) return i;}}else if (t==r) {var e=KM(e, QS);var a=QS[e];return (typeof(a)!=un && a && a.toString() ? e:"");}else Err(e2+"().Key("+(e?e:"")+")");Err(e1+"().Item("+e+")");};QS.Key.toString=function() {Err(e2+"().Key");}
this.QueryString=function(k) {if (typeof(k)==un) return QS;else {var k=KM(k, QS);if (typeof(QS[k])==un) {t=new Object();t.Count=function() {return 0};t.Count.toString=function() {return "0"};t.toString=function() {return un};t.Item=function(e) {return un};t.Item.toString=function() {return un};t.Key=function(e) {Err(e3+"("+(e?e:"")+")");};t.Key.toString=function() {return un};return t;}if (typeof(k)==n) return QS.Item(k);else return QS[k];}}
this.QueryString.toString=function() {return LS.toString();};this.QueryString.Count=function() {return (TC ? TC:0)};this.QueryString.Count.toString=function() {return (TC ? TC.toString():"0")};this.QueryString.Item=function(e) {if (typeof(e)==un) return LS.toString();else {if (typeof(e)==n) {var e=Math.ceil(e);var c=0;for (var i in QS) {if (typeof(QS[i])!=f && ++c==e) return QS[i];};Err(e1+".Item("+e+")");}else return QS[KM(e, QS)];}if (typeof(e)==(n)) Err(e1+".Item("+e+")");return un;}
this.QueryString.Item.toString=function() {return LS.toString()};this.QueryString.Key=function(e) {var t=typeof(e);if (t==n) {var e=Math.ceil(e);var c=0;for (var i in QS) {if (typeof(QS[i])=="object" && (++c==e)) {return i;}}}else if (t==r) {var e=KM(e, QS);var a=QS[e];return (typeof(a)!=un && a && a.toString() ? e:"");}else Err(e2+".Key("+(e?e:"")+")");Err(e1+".Item("+e+")");};this.QueryString.Key.toString=function() {Err(e2+".Key");};this.Version=1.1;this.Author="Andrew Urquhart (www.andrewu.co.uk)";}
var Request=new RObj(false);


Esses são os códigos.
Então, alguém?

WITHOUT A NICK


P.S.: A página paceria.cfm está certa?

Edição feita por: Without a Nick, 27/09/2003, 18:58.


#3 Guilherme Blanco

Guilherme Blanco

    Loading...

  • Conselheiros
  • 891 posts
  • Sexo:Masculino
  • Localidade:São Carlos - SP/Brasil
  • Interesses:Programação Web e minha namorada (Maria Camila).

Posted 28/09/2003, 16:10

Jogue o argumento para o target também... isto resolve seu problema...

Vou tentar exemplificar com PHP:

<html>
  <head>
    <title>Parceria</title>
  </head>

  <frameset rows="88,*" framespacing="0" border="0" frameborder="0">
    <frame name="cabecalho" scrolling="no" noresize target="principal" src="parceria/up.html">
    <frame name="principal" src="parceria/down.html" scrolling="auto">
  </frameset>
</html>

Essa é sua página, certo??? Você quer passar o ID para o frame de baixo... simples!

index.php?id=120

Seu código ficaria assim:

<?php
  if( ! empty($_GET[id]) ) { $theUrl = "parceria/down.php?id=".$_GET[id]; }
  else { $theUrl = "parceria/down.php"; }
?>
<html>
  <head>
    <title>Parceria</title>
  </head>

  <frameset rows="88,*" framespacing="0" border="0" frameborder="0">
    <frame name="cabecalho" scrolling="no" noresize target="principal" src="parceria/up.html">
    <frame name="principal" src="<?php echo $theUrl; ?>" scrolling="auto">
  </frameset>
</html>

Agora, na página down.php você faz a análise para o id=120... =)

Espero ter te dado uma dica de como resolver seu problema...

[]s,
<script language="WebFórum">
// Dados:
Nome("Guilherme Blanco");
Localidade("São Carlos - SP/Brasil");
Cargo("Manutenção");
</script>

#4 Without a Nick

Without a Nick

    Sem culpa no cartório

  • Usuários
  • 2378 posts
  • Sexo:Não informado
  • Localidade:Guarulhos

Posted 28/09/2003, 19:39

É, deu uma noção, mas tem um problema: o host que eu estou hospedando (kit.net) não aceita códigos PHP. Então, por isso é que eu gostaria de saber se tem como fazer isso em JavaScript.


WITHOUT A NICK

#5 Guilherme Blanco

Guilherme Blanco

    Loading...

  • Conselheiros
  • 891 posts
  • Sexo:Masculino
  • Localidade:São Carlos - SP/Brasil
  • Interesses:Programação Web e minha namorada (Maria Camila).

Posted 28/09/2003, 22:21

Via JS??

Entre neste endereço e leia o artigo:
http://www.webfx.eae...argPassing.html

Caso alguma coisa, entre em contato comigo.

[]s,
<script language="WebFórum">
// Dados:
Nome("Guilherme Blanco");
Localidade("São Carlos - SP/Brasil");
Cargo("Manutenção");
</script>




1 user(s) are reading this topic

0 membro(s), 1 visitante(s) e 0 membros anônimo(s)

IPB Skin By Virteq