That's inaccessible, if someone has Javascript disabled they won't be able to see the content, I'd use AJAX:
HTML Code:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>JS</title>
<style type="text/css">
#left{
float:left;
width: 150px;
height: 600px;
}
#right{
float:left;
width: 550px;
height: 600px;
}
</style>
<script type="text/javascript">
/* <![CDATA[ */
function GetRequestObject(){
var XMLHttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
XMLHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
XMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
XMLHttp = false;
}
}
@else
XMLHttp = false;
@end @*/
if (!XMLHttp && typeof XMLHttpRequest != 'undefined') {
try {
XMLHttp = new XMLHttpRequest();
} catch (e) {
XMLHttp = false;
}
}
return XMLHttp;
}
function GetPage(linkObj){
Request = GetRequestObject();
if(!Request){
window.location.href = linkObj.href;
}
Request.open("GET", linkObj.href ,true);
Request.onreadystatechange = function(){
if(Request.readystate == 4 || Request.readyState == 4){ // Successfully sent
var File = Request.responseText.substring(Request.responseText.indexOf('<body>'), Request.responseText.indexOf('</body>')+7);
document.getElementById("right").innerHTML = File;
}
};
Request.send(null);
}
/* ]]> */
</script>
</head>
<body>
<div id="left">
<a href="one.html" onclick="GetPage(this); return false;">One</a>
<a href="two.html" onclick="GetPage(this); return false;">Two</a>
</div>
<div id="right">
</div>
</body>
</html>
Of course it would be better to create a template file, seperate the JS into a seperate file and use an XML object and parser to target the content ("right") div but that's for another discussion.
Bookmarks