Jump to content


g-prime's Content

There have been 3 items by g-prime (Search limited from 19/04/2023)


Ordernar por                Order  

#1009811 Escolher Div Que Exibe Página

Posted by g-prime on 06/05/2011, 00:34 in Ajax

ola procure por lytebox acho que é isso que vc procura


não é bem isso nao..., eu quero abrir uma pagina numa div, só que quero escolher as divs que vao ser abertas

tipo

<a href="#" onclick="abrirpag('home.html','div_conteudo')">home</a>
<a href="#" onclick="abrirpag('empresa.html','div_topo')">empresa</a>



#1009748 Escolher Div Que Exibe Página

Posted by g-prime on 04/05/2011, 00:10 in Ajax

Pessoal, tudo bom?

Estou iniciando em ajax e tenho um problema que nao consegui resolver, por isso venho aqui pedir ajuda.

Tenho um código de ajax que abre uma página dentro de uma div (como se fosse iframe).

só que quando executo a função atravez de onclick, em outras palavras, qnd clico no link com a função, ele traz a página e exibe na div pré determinada para isso.

Eu preciso que eu possa escolher no onclick a página que abre(isso ja da para fazer) e a div.

Tentei de varias formas, mais não obitive sucesso.
não queria usar jquery para fazer isso pq facilita muito e eu quero aprender mais sobre ajax =)

alguem pode me ajudar?

código:

Ajax.js

function GetXMLHttp() {
if(navigator.appName == "Microsoft Internet Explorer") {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else {
xmlHttp = new XMLHttpRequest();
}
return xmlHttp;
}

var xmlRequest = GetXMLHttp();

-------------------------------------------

instrucao.js

function abrirPag(valor){
var url = valor;

xmlRequest.open("GET",url,true);
xmlRequest.onreadystatechange = mudancaEstado;
xmlRequest.send(null);

if (xmlRequest.readyState == 1) {
document.getElementById("conteudo_mostrar").innerHTML = "<div style='width:100px; height:100px; margin:0 auto; font-family:Verdana; font-size:9px; color:#999;'><center><img src='loading.gif'><br><br />Aguarde</center></div>";
}


return url;
}

function mudancaEstado(){
if (xmlRequest.readyState == 4){
document.getElementById("conteudo_mostrar").innerHTML = xmlRequest.responseText;
}
}

-----------------------------------------------------------

html:

<a herf="javascript:void(0);" onclick="abrirPag('pagina.html');">link</a>
<div id="conteudo_mostrar"></div>


PS: a maneira que tentei fazer isso foi a seguinte
<a herf="javascript:void(0);" onclick="abrirPag('pagina.html','conteudo_mostrar');">link</a>

não funcionou...=/

Obrigado! :rolleyes:



#1005355 Ao Clicar No Link, Mostra A Div, Ao Clicar Em Outro Lugar, Oculta A Di

Posted by g-prime on 09/11/2010, 09:32 in Javascript / DOM / AJAX / ECMAScript

Opa galera, blz?

desenvolvi um esquema meio "nas coxa", mais funciona muito bem (e ja estou usando xD)
é meio que um ligthbox (daqueles que vc clica do lado de fora da imagem pra fechar)






<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR...nsitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
//abre a div com o conteudo e a div de fora
function abre(){
document.getElementById('div1').style.display = "block";
document.getElementById('div2').style.display = "block";
}
//fecha a div com o conteudo e a div de fora
function fecha(){
document.getElementById('div1').style.display = "none";
document.getElementById('div2').style.display = "none";
}
</script>
<style>
</style>
</head>

<body>
<div style="width:100%; height:100%; left:0px; top:0px; position:fixed; z-index:100; display:none;" id="div1" onclick="fecha();"></div>

<a href="#" onclick="abre();" id="bot">abrir</a><br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />
teste de linha <br /><br />


<div style="width:300px; height:200px; margin:auto; position:absolute; top:20%; z-index:200; border:2px solid #000; background-attachment:fixed; display:none; text-align:center; padding-top:30px;" id="div2">
<a href="#" onclick="fecha();" id="bot">fechar</a>
</div>
</body>
</html>


espero ter ajudado xD
anexei o arquivo que usei pra fazer, so baixar e pronto hehehehe

abraços /o/

Attached Files





IPB Skin By Virteq