Jump to content


Photo

Url Direta (Div Carregado Por Ajax)


  • Faça o login para participar
1 reply to this topic

#1 rpweb

rpweb

    Novato no fórum

  • Usuários
  • 1 posts
  • Sexo:Masculino
  • Localidade:Curitiba/PR

Posted 03/11/2011, 13:09

Olá, estou com um probleminha relacionado a url da pagina gostaria de linkar algumas paginas em especifico em lugares externos da pagina mas a url fica fixa(layout estatico), teria como puxar o conteudo carregado dentro da div pelo url??? para link externo???


Ajax.js
var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function AbrirPagina(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('REQUEST', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

Index.php:
Link aplicado:
<a href"javascript:AbrirPagina('paginacarregada.php','conteudo')">link</a>(usado dentro e fora da div)

<div id=conteudo>conteudo carregado<div>

Grato.

#2 Goku Jr

Goku Jr

    Nilson

  • Usuários
  • 3757 posts
  • Sexo:Masculino

Posted 23/11/2011, 12:36

E só exibir a página dentro de uma DIV ou IFRAME.
-----------------------------------------------------------------------
PALMEIRAS - Primeiro campeão do mundo em 1951




1 user(s) are reading this topic

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

IPB Skin By Virteq