This depends on client browser rather than server.
What we are doing -
- Calling a php script random.php using XML HTTP Request from a pure HTML file
- random.php prints the actual content returned from CpmFetch
- We are populating a div with this content
- You can use any element instead of div
Add the following Java Script code to your html file in which you want to fetch the photos (normally within head tag of the html).
<script language="Javascript">
<!--
var x1;
x1 = createRequestObject();
function createRequestObject() {
var x = false;
try {
x = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
x = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
x = false;
}
}
if (!x && typeof XMLHttpRequest != "undefined") {
x = new XMLHttpRequest();
}
return x;
}
function getPhotos() {
x1.open('get','random.php'); //Replace random.php with whatever php script you are using to fetch photos
x1.onreadystatechange = function() {
if (x1.readyState == 4) {
document.getElementById("photos").innerHTML = x1.responseText;
}
}
x1.send(null);
}
onload = getPhotos();
//-->
</script>
and this is a sample html
<table>
<tr>
<td>this is some text</td>
<td>
<div id="photos">
</td>
</tr>
</table>
In above html code the div with id="photos" will get populated with the photos. You can place this div anywhere you want in your html. Infact you can use any element instead of div to accomplish this but make sure that id of that element is
photosAnd this is sample
random.php<?php
include "./cpmfetch/coppermine.php";
$objCpm = new cpm("/cpg133");
print $objCpm->cpm_viewRandomMediaFromCategory(4,2,0);
$objCpm->cpm_close();
?>
In random.php replace the paths and function name as per your needs.
I am attaching a sample html file which will help you understand this better.