mayamanako
Technical User
hi guys, i am testing this code below which i've seen from this:
i would like to know if you have ideas how i could make the external page load automatically as soon as the 'parent' page loads without clicking the link?
thanks for any inputs.
i would like to know if you have ideas how i could make the external page load automatically as soon as the 'parent' page loads without clicking the link?
thanks for any inputs.
Code:
function fetch(URL, divId) {
req = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0");
req.open("GET", URL, true);
req.onreadystatechange = function() {
if (req.readyState == 4 && req.status == 200) {
document.getElementById(divId).innerHTML = req.responseText;
}
}
req.send(null);
}
Save the above code as fetcher.js. Then include it in your html/php/whatever page:
<script language="javascript" src="fetcher.js"></script>
The last step is to create the a <div> to load the content into and the link that would actually do it:
<div id="container_div" class="container">Some default text<div>
<a href="#" onclick="fetch('url_of_page_to_fetch.php?with=arguements', 'container_div')">fetch</a>