HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>Basic TAB display</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function more(el,le){
el.innerHTML = el.innerHTML.replace(new RegExp("(.{"+le+"})(.*)","ig"),'$1<span style="display:none;">$2</span><a href="#" onclick="handle(this);">More</a>');
}
function handle(el){
if (el.innerHTML==="More"){
el.parentNode.getElementsByTagName("span")[0].style.display="inline";
el.innerHTML="Less";
}
else {
el.parentNode.getElementsByTagName("span")[0].style.display="none";
el.innerHTML="More";
}
}
window.onload = function(){
more(document.getElementById("whatever"),10);
}
</script>
</head>
<body>
<div id="whatever">
Here is a really long piece of text, but I think that I will just cut it short early.
</div>
</body>
</html>
Bookmarks