I have been trying to load a javascript function from the body onload
html tag, but I only want the function to load the first time the page
is loaded: I have investigated but haven't found anything that works..
I thought about cookies, but what if the user's disable them?
My code:
//I want to call the Toggle function below only on the 1st time the
page is loaded:
<script language="javas cript">
function Toggle(item) {
obj=document.ge tElementById(it em);
visible=(obj.st yle.display!="n one")
key=document.ge tElementById("x " + item);
if (visible) {
obj.style.displ ay="none";
} else {
obj.style.displ ay="block";
}
}
function Expand() {
divs=document.g etElementsByTag Name("DIV");
for (i=0;i<divs.len gth;i++) {
divs[i].style.display= "block";
key=document.ge tElementById("x " + divs[i].id);
key.innerHTML=" <img src='textfolder .gif' width='175' height='25'
hspace='0' vspace='0' border='0'>";
}
}
function Collapse() {
divs=document.g etElementsByTag Name("DIV");
for (i=0;i<divs.len gth;i++) {
divs[i].style.display= "none";
key=document.ge tElementById("x " + divs[i].id);
key.innerHTML=" <img src='Button1_01 _over.gif' width='179'
height='37' hspace='0' vspace='0' border='0'>";
}
}
</script>
// C# code I inserted above the body tag on my aspx page:
function handler()
{
if(<%=!Page.IsP ostBack%> )
{
Toggle('support ');
}
}
//The body tag with handler being called:
<body onload="handler ()">
FYI: The Toggle('suport) ; function is not being executed. If i put the
function in the <body onload tag.. it does run..