How can I get the innerHTML of a <div> area only when the page loads, then use that variable in a function?
Here is my code:
function setContent(zz)
{
var lb = document.getElementById('leftbar').innerHTML;
var rb = document.getElementById('rightbar').innerHTML;
document.getElementById("myContent").innerHTML = "<span class=\"title_Page\">"+Page[zz]+"</span>";
if (zz=="home") {
document.getElementById('leftbar').innerHTML = lb;
document.getElementById('rightbar').innerHTML = rb;
document.getElementById('leftbar').style.width = '135px';
document.getElementById('rightbar').style.width = '135px';
}
else {
document.getElementById('leftbar').innerHTML = "";
document.getElementById('rightbar').innerHTML = "";
document.getElementById('leftbar').style.width = '0px';
document.getElementById('rightbar').style.width = '0px';
}
}
I want lb and rb to be set only once (i.e. only when the page loads the first time). I tried putting those variables outside the function, but when I do they, they show up as undefined. So how could i code it so that when the page loads, it assigns the innerHTML to the two variables, but not any other time while that page is open?
Chris
--
Composed with Newz Crawler 1.4 http://www.newzcrawler.com/