473,783 Members | 2,516 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calling javascript function once - from the <body onload="myfunct ion"> 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="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..

Nov 23 '05 #1
1 8742
lwhitb1 wrote on 23 nov 2005 in comp.lang.javas cript:
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
3168
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 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:
5
6506
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); td.onclick = myfunction; function myfunction(event) { alert(event);
11
2458
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"> ..historylinks {
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.