[ toxi_programer @ 31.03.2008. 15:54 ] @
Sledi kod koji sam do sada našao. On radi baš ono što meni treba, ali taj kod radi samo u Internet Exporeru, a potrebno je da radi i u ostalim browserima. Evi ih dve bitne funkcije: Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test</title> <script language="JavaScript" type="text/javascript"> <!-- function getXmlHttp() { var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp } function feedDivWithHTML ( elementID, targetURL ) { var xmlhttp = getXmlHttp(); if ( xmlhttp ) { var loader = document.getElementById( elementID + "Loading" ); xmlhttp.open("GET", targetURL , true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { var mainDiv = document.getElementById(elementID); mainDiv.innerHTML = xmlhttp.responseText; } } xmlhttp.send(null) } } //--> </script> </head> E, da bih ih pozvao koristim ovaj kod: Code: <body> <div id="TargetDiv"></div> <script language="JavaScript" type="text/javascript"> <!-- feedDivWithHTML ( 'TargetDiv', 'http://urlMojeStrane' ); //--> </script> </body> </html> Dakle, ovo će pozvati neku stranicu sa "MojeStrane" i ono što dobije( html kod) smestiti u <div> tag. Problem je u dobijanju html koda druge neke stranice - taj deo radi u IEu ali ne radi u ostalim browserima... Kako to da ispravim? Uzgred, ovo MORA da radi u html stranicama, da ne mora bilo bi lako uraditi preko PHPa, ASPa itd... |