You are here: irt.org | FAQ | JavaScript | Cookie | Q403 [ previous next ]
It can be done using cookies, although a lot of people disable cookies. Another alternative is to have a frameset with a hidden frame. You store a variable in the parent frame which says whether the main frame has already been loaded. Each time the main frames loads it checks the parent frame for the variable value to see whether it should perform the once only code:
<head> <script language="JavaScript"><!-- var displayed_it_yet = false; //--></script> </head> <frameset rows="100%,*"> <frame src="mainpage.htm"> <frame src="about:blank"> </frameset>
And then in mainpage:
<script language="JavaScript"><!-- function check_first() { if (!parent.displayed_it_yet) { // code to perform parent.displayed_it_yet = true; } } //--></script>