|
Posted by shubeer on 07/12/06 21:48
Hi Robert,
Iframes are good, and they work well accross browsers. They can also
be styled to blend in to the page and create the impression that the
user is looking at one page.
Anyway, if it makes any difference, I'd also like to provide another
possible solution to your question. If you use AJAX, you can achieve
the same kind of effect. I have attached two pieces of code below.
Just put it in your webroot folder and call index.html.
--------------------------------------index.html-------------------------------------
<html>
<head>
<script type="text/javascript" language="javascript">
var xmlhttp;
function loadXMLDoc() {
xmlhttp = null;
if (window.XMLHttpRequest) {
xmlhttp=new XMLHttpRequest();
} else if (window.ActiveXObject) {
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null) {
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4)
if (xmlhttp.status==200) {
document.getElementById("refresher_div").innerHTML =
xmlhttp.responseText;
setTimeout("loadXMLDoc()", 1000);
}
};
xmlhttp.open("GET","time.php",true);
xmlhttp.send(null);
} else {
alert("Your browser does not support XMLHTTP.");
}
}
</script>
</head>
<body>
<center>
<div name="refresher_div" id="refresher_div">
Time will display here!!
</div>
</center>
</body>
</html>
<script language="javascript">
loadXMLDoc();
</script>
--------------------------------------time.php----------------------------------------
<?= date("r") ?>
=============================================
What's happening here is that the index.html page is using AJAX to make
a call to the time.php script which simply provides the current time on
the server and the index.html page then displays the time on the
server.
It's a rather contrived example, but it just shows you how you can
achieve your intended goal using another method.
Regards,
Shubeer
Navigation:
[Reply to this message]
|