473,320 Members | 2,189 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,320 software developers and data experts.

need to run code once rather than every time

121 100+
Hi,
i am using window.onload in HTML code which is like
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" language="javascript">
  2.  
  3.     window.onload = function(){
  4.       ShowPanel1(); 
  5.       return false;
  6.     }
  7.     </script>
where ShowPanel() is a function, now i have one dropdown in my form and their is a selectindexchanged postback on it, so every time dropdown is changed , this above code runs. Is their any way that this code runs only once when page initially loads. something like postback check in javascript??

Any help will be appreciated.

Regards
Jay
Jul 22 '10 #1
1 1500
Dormilich
8,658 Expert Mod 8TB
I am not aware, that JavaScript can differenciate between initial load and reload, due to the stateless nature of HTTP.

however you can use several tricks to tell the initial script, whether it should execute or not.
- you can set a cookie, which you check before loading
- you can make the server print or omit the JS code (e.g. depending on a session)
- you can pass an URL parameter to suppress execution of the initial function
- etc.
Jul 22 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Chad | last post by:
I have COM component embedded on html page. It has version 1.0.0.1 (by default). I have converted it in cab file. Code of html is something like: <HTML><HEAD></HEAD><BODY><OBJECT...
8
by: Scott M | last post by:
I have a procedure in my Dispose method that records my application was closed in a database. However, when I kill a process or an unhandled exception occurs this does not seem to run. Is there...
3
by: CptDondo | last post by:
I am working on an embedded system. The entire configuration for the system is stored in an XML file, which is pretty long. It takes about 3 seconds to open the file using domxml_open_file. ...
6
by: Bill | last post by:
Hi all, How would I set up a script to run every time a user comes to a page (even if they come to the page via the back button)? Thanks! Bill
3
by: Michiel Rapati-Kekkonen | last post by:
hi, once upon a time I read that the communication with the back end would be faster if one table there was kept open. For that purpose you were supposed to make an otherwise useless table in...
26
by: Ravindra.B | last post by:
I have declared a global variable which is array of pointers and allocated memory for each array variable by using malloc. Some thing similar to below... static char *arr; main() { int i;
5
by: aj | last post by:
SQL Server SP2 9.0.3042 64-bit I recently put my first SQL Server DB in production. In the "other" database that I use (not interested in any arguments), you can indicate the desired size of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.