Posted by J.O. Aho on 01/15/07 12:20
CRON wrote:
> Hi!,
> Anyone know a way to save on loading times by only loading part of the
> page after a link is clicked? iframes is an obvious solution but it
> would be messy. Is it possible to change the content of a div when a
> link is clicked?
Yes, you can do that with help of javascript (even jscript works, but then you
lock out a good number of users)
--- javascript ---
function showdiv(id)
{
el = document.getElementById(id);
if (el.style.display == 'none') {
el.style.display = '';
el = document.getElementById('_' + id);
} else {
el.style.display = 'none';
el = document.getElementById('_' + id);
}
return false;
}
--- eof ---
--- the div ---
<div id="divID">Something here!</div>
--- eof ---
--- the link ---
<a href="" title="The Link" onclick="javascript:showdiv('divID');return
false;">The Link to show or hide div named divID</a>
--- eof ---
Should work on all javascript supporting browsers.
--
//Aho
[Back to original message]
|