Passagem de valor entre páginas usando JavaScript com IFRAME

27/04/2009

0

Olá Pessoal!

Me ajudem por favor...

Sou iniciante, estou com a seguinte dúvida:

Minha página está assim:

Tenho uma página Principal, que divide a página em três frames: INFERIOR, SUPERIOR, CENTRAL. Conforme código abaixo:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>.:: Projeto ::.</title>
</head>
<frameset rows="100,*,20" frameborder="0" framespacing="0">
<frame src="Topo.aspx" name="superior" noresize scrolling="NO">
<frame src="corpo.html" name="central" marginwidth="0" marginheight="0" noresize scrolling="YES">
<frame src="rodape.aspx" name="inferior" noresize scrolling="NO">
</frameset>
<noframes>
<body style="margin-top: 0px; margin-left: 0px;">
</body>
</noframes>
</html>


Na página ´CORPO.HTML´ tenho dois outros frames, conforme codigo abaixo:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<frame name="Corpo" src="corpo.aspx" marginwidth="0" marginheight="0" noresize scrolling="YES">
<TITLE>Area de Trabalho do Projeto</TITLE>
<meta name="vs_defaultClientScript" content="JavaScript" />
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5" />
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0" />
<meta name="ProgId" content="VisualStudio.HTML" />
<meta name="Originator" content="Microsoft Visual Studio.NET 7.0" />
</head>
<frameset border="1" frameborder="0" framespacing="0" cols="240,*">
<frame name="menu" src="menu.aspx" marginwidth="0" marginheight="0" noresize scrolling="YES">
<frame name="corpo" src="AreaTrabalho.aspx" marginwidth="0" marginheight="0" noresize scrolling="YES">
</frameset>
<body>
<form id="frmCorpo" />
</body>
</html>



Daí o que acontece.. no arquivo ´Menu.ASPX´, eu tenho o seguinte JS:

<script type=´text/javascript´>
function cpg(p)
{
parent.corpo.location=p;
}
</script>

Ele desenha, qualquer página no FRAME Corpo (AreaTrabalho.ASPX)

Dentro do Menu, eu tenho um link que usa este JS, da seguinte forma abaixo:

   - "javascript:cpg(´Movimento/Certificado.aspx´)"


Então a página ´CERTIFICADO.ASPX´ será desenhada no FRAME - AREATRABALHO.ASPX (CORPO).

Dentro da página ´CERTIFICADO.ASPX´ tenho um botão que chama a página ´PESQEMPRESA.Aspx´, através do seguinte javascript:

Evento do botão:

        ScriptManager.RegisterStartupScript(UpdPnlPrincipal, UpdPnlPrincipal.GetType(), "PesqEmpresa", "openModal(´../Cadastro/CadEmpresa.aspx´, 665, 400);", True)


O JavaScript:

function openModal(pUrl, pWidth, pHeight) {
if (window.showModalDialog) {
return window.showModalDialog(pUrl, window,
  "dialogWidth:" + pWidth + "px;dialogHeight:" + pHeight + "px");
} else {
try {
netscape.security.PrivilegeManager.enablePrivilege(
  "UniversalBrowserWrite");
window.open(pUrl, "wndModal", "width=" + pWidth
  + ",height=" + pHeight + ",resizable=no,modal=yes");
return true;
}
catch (e) {
alert("Script não confiável, não é possível abrir janela modal.");
return false;
}
}
}


A função javascript acima está implementada assim:

function

openModal(pUrl, pWidth, pHeight) {
if (window.showModalDialog) {
return window.showModalDialog(pUrl, window,´dialogWidth:´+ pWidth+´px;dialogHeight:´ + pHeight + ´px´);
} else {
try {
netscape.security.PrivilegeManager.enablePrivilege(´UniversalBrowserWrite´);
window.open(pUrl, ´wndModal´, ´width=´ + pWidth+ ´,height=´ + pHeight +,resizable=no,modal=yes´);
return true;
} catch (e) {
alert(´Script não confiável, não é possível abrir janela modal.´);
return false;
}
}
}

A idéia é que na página ´PesqEmpresa.aspx´, a pessoa faça a pesquisa de uma lista de empresas, e nela tenha, para cada item listado do banco de dados, um botão ´SELECIONAR´, o qual deve carregar para um campo (texto) da página anterior (CERTIFICADO.ASPX, por exemplo), o ´ID´ do registro selecionado.

Na página ´PesqEmpresa.aspx´, coloquei os seguintes códigos:

[b]        jscript = "window.opener.document.forms[´Certificado´].txbCnpjCpf.value = ´" + "00.000.000/0001-00" + "´;"
        jscript = "window.opener.document.forms[´Certificado´].txbCnpjCpf.value = ´" + "00.000.000/0001-00" + "´;"
        ´ "parent.frames[´" + "´corpo´" + "´].document.forms[´" + "Certificado" + "´].txbCnpjCpf.value = ´" + "00.000.000/0001-00" + "´;"
        jscript = "javascript:setvalorcampo(1,´txbCnpjCpf´,´12345678´);"
        jscript = "window.opener.document.location.href = ´" + "´None.aspx´" + "´;"
        jscript += "window.opener.document.getElementById(´txbCnpjCpf´).value = ´" + "00.000.000/0001-00" + "´"
        ´"´" + varCnpjCpf + "´;"
        ´opener.document.NomeDoForm.submit();
        ´window.opener.forms["document.frmEnvia"].submit();
        jscript = "window.opener.parent.frames[´" + "´corpo´" + "´].forms[´" + "´Certificado´" + "´].txbCnpjCpf.value = ´" + "00.000.000/0001-00" + "´;"
        jscript = "window.opener.parent.corpo.document.forms.Certificado.txbCnpjCpf.value = ´" + "00.000.000/0001-00" + "´;"
        jscript = "alert(top.opener.Text1.value);"
        jscript += "alert(top.opener.forms[´frmDefault´].Text1.value);"
        jscript += "alert(self.opener.location.href);"
        jscript += "alert(self.opener.document);"
        jscript += "alert(self.opener.document.forms.length);"
        jscript += "alert(self.opener.document.formname);"
        jscript += "alert(self.opener.document.formname.elements.length);"
        jscript += "alert(self.opener.document.formname.fieldname);"
        jscript += "alert(self.opener.document.formname.fieldname.value);"
        jscript += "window.close();"[/b]


Porém nenhum funcionou, dá a seguinte mensagem:

Objeto inválido ou Nulo!

Ou seja, é como se eu estivesse acessando nd.

[b:0fcc38206d]SE PUDEREM ME AJUDAR, AGRADEÇO!!![/b:0fcc38206d]

ABRAÇO!

CURIOSA!!!


Curiosa

Curiosa

Responder

Posts

28/04/2009

Curiosa

SOBRE


Responder

04/05/2009

Curiosa

SOBE


Responder

05/05/2009

Signori

Olá Curiosa,

Este erro está acontecendo no JavaScript? acho que uma forma mais fácil seja seguir aquele tópico sobre Chave Estrangeira, que havia indicado em um post anterior.

Verifica se vc não está chamando algum componente HTML que não existe, ou está com outro nome.

Da uma olhada...

Abraço


Responder

Assista grátis a nossa aula inaugural

Assitir aula

Saiba por que programar é uma questão de
sobrevivência e como aprender sem riscos

Assistir agora

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar