putting another page in div tag?
i have following code for inserting another page into div
An XHTML 1.0 Strict standard template
</style>
<script type="text/javascript">
function ajaxFunction(id, url){
var xmlHttp;
try {// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) {// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
alert("Your browser does not support AJAX!");
return false;
}
开发者_C百科}
}
xmlHttp.onreadystatechange = function(){
if (xmlHttp.readyState == 4) {
//Get the response from the server and extract the section that comes in the body section of the second html page avoid inserting the header part of the second page in your first page's element
var respText = xmlHttp.responseText.split('<body>');
elem.innerHTML = respText[0].split('</body>')[0];
}
}
var elem = document.getElementById(id);
if (!elem) {
alert('The element with the passed ID doesn\'t exists in your page');
return;
}
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
http://www.boxyourtvtrial.com/');"/>
but its not working properly i also put google in address but still its not working whats wrong with the code....
XMLHTTPRequest
is not allowed to make requests any domain other than the one the HTML page was served from.
Here's some info on getting around that restriction.
If you want to embed another page, you can use an iframe
. When the page is from another domain, you won't be able to access the contents of the iframe
from the main page, however.
If you really need to embed another page, load the page on your server (using a HTTP client framework for your language) and then send it to the client as the result of the AJAX request.
Note that this is usually considered abuse or to be outright illegal without the permission of the site owner (copyright, bandwidth, etc.).
精彩评论