Kod
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>AXAH (Asynchronous XHTML and HTTP) - Crawl before you AJAX</title>
<script language="JavaScript" type="text/JavaScript">
//object detection to return the correct object depending upon broswer type. Used by the getAXHA(); function.
function getNewHttpObject() {
var objType = false;
try {
objType = new ActiveXObject('Msxml2.XMLHTTP');
} catch(e) {
try {
objType = new ActiveXObject('Microsoft.XMLHTTP');
} catch(e) {
objType = new XMLHttpRequest();
}
}
return objType;
}
//Function used to update page content with new xhtml fragments by using a javascript object, the dom, and http.
function getAXAH(url,elementContainer){
document.getElementById(elementContainer).innerHTML = '<blink class="redtxt">Loading...<\/blink>';
var theHttpRequest = getNewHttpObject();
theHttpRequest.onreadystatechange = function() {processAXAH(elementContainer);};
theHttpRequest.open("GET", url);
theHttpRequest.send(false);
function processAXAH(elementContainer){
if (theHttpRequest.readyState == 4) {
if (theHttpRequest.status == 200) {
document.getElementById(elementContainer).innerHTML = theHttpRequest.responseText;
} else {
document.getElementById(elementContainer).innerHTML="<p><span class='redtxt'>Error!<\/span> HTTP request return the following status message: " + theHttpRequest.statusText +"<\/p>";
}
}
}
}
</script>
<style type="text/css">
<!--
/* ----- Uncomment the global selector below to over-ride the default margin and padding added to all tags ----- */
*{padding: 0; margin: 0;}
/* ----- global default/initial styles ----- */
body {background-color:#fff; margin: 10px; padding: 0;}
/* ----- base default font size, type, and line height ----- */
html body{font: 62.5%/1.4em Arial, Helvetica, sans-serif;color:#333333}
html>body{font: 62.5%/1.4em Arial, Helvetica, sans-serif;color:#333333}
/* ----- add selectors here for font sizing ----- */
p, table, ul, dl {font-size: 1.2em}
caption {font-size: 1.4em}
h2 {font-size: 1.6em}
/* ----- base links ----- */
a:link {color: #CC6633;}
a:visited {color: #CC6633;}
a:hover {color: #999966;}
a:active {color: #CC6633;}
a:focus{color: #CC6633;}
p {line-height:1.4em;margin:10px 0;}
ul li {display:inline}
hr{margin:10px 0;color:#999999;}
.bluetxt{color:#0000FF}
.redtxt{color:#FF0000}
.greentxt{color:#006600}
-->
</style>
</head>
<body>
<p><a href="http://codylindley.com/Javascript/237/axah-asynchronous-xhtml-and-http-crawl-before-you-ajax">What is this?</a></p>
<ul>
<li><a href="1.html" onclick="getAXAH('1.html','content');return false;">Load blue Lorem Ipsum <strong>bold</strong> text</a> ‌ </li>
<li><a href="2.html" onclick="getAXAH('2.html','content');return false;">Load green Lorem Ipsum <em>italic</em> text </a> ‌ </li>
<li><a href="3.html" onclick="getAXAH('3.html','content');return false;">Load red Lorem Ipsum regular text </a></li> ‌
<li><a href="Lorem-ipsum-nothing.htm" onclick="getAXAH('Lorem-ipsum-nothing.htm','content');return false;">Show example of Error</a></li>
</ul>
<hr size="1px" />
<div id="content">
<p>Select Lorem Ipsum color and font type above to be displayed here.</p>
</div>
</body>
</html>
korzystam z czegoś takiego wtedy gdy kliknę w którykolwiek z linków to mi w tym divie odpala stronkę. dało by się to zmodyfikować jak dla iframow?