473,387 Members | 1,520 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

calling javascript function once - from the <body onload="myfunction"> tag

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="javascript">

function Toggle(item) {

obj=document.getElementById(item);
visible=(obj.style.display!="none")
key=document.getElementById("x" + item);
if (visible) {
obj.style.display="none";
} else {
obj.style.display="block";
}

}
function Expand() {
divs=document.getElementsByTagName("DIV");
for (i=0;i<divs.length;i++) {
divs[i].style.display="block";
key=document.getElementById("x" + divs[i].id);
key.innerHTML="<img src='textfolder.gif' width='175' height='25'
hspace='0' vspace='0' border='0'>";
}
}

function Collapse() {
divs=document.getElementsByTagName("DIV");
for (i=0;i<divs.length;i++) {
divs[i].style.display="none";
key=document.getElementById("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.IsPostBack%> )
{
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..

Nov 23 '05 #1
1 8693
lwhitb1 wrote on 23 nov 2005 in comp.lang.javascript:
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?

What does "only once" mean?

Different users from the same machine?

Same user on different machines?

Same user on different IP and same laptop?

Me seems you should define your quest.

What about having the user log in on your site,
and using a database and serverside script get to your goal.
--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: lwhitb1 | last post by:
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...
5
by: Jason | last post by:
Hello, I am trying to dynamically create a table, then set its <td>'s onclick: var table = document.createElement("table"); var row = table.insertRow(-1); var td = row.insertCell(-1);...
11
by: jesdynf | last post by:
I'm having trouble applying a stylesheet to content I'm generating after the fact. Here's the sample code: <html> <head> <title>CSS/DOM Problem Example</title> <style type="text/css">...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.