Question : execute onLoad only once in an ASP page

looking for a way to execute onLoad for the BODY tag only once in an ASP page.  see below:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<%
Set fso = CreateObject("Scripting.FileSystemObject") 
If (fso.FileExists("C:\inetpub\message.txt"))=true then
	onLoadString = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';"
Else
	onLoadString = ""
End If
Set fso = Nothing
%>

<head>
<style>
		.black_overlay{
			display: none;
			position: absolute;
			top: 0%;
			left: 0%;
			width: 100%;
			height: 100%;
			background-color: black;
			z-index:1001;
			-moz-opacity: 0.8;
			opacity:.80;
			filter: alpha(opacity=80);
		}
		.white_content {
			display: none;
			position: absolute;
			top: 25%;
			left: 25%;
			width: 50%;
			height: 50%;
			padding: 16px;
			border: 1px solid black;
			background-color: white;
			z-index:1002;
			overflow: auto;
		}
	</style>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST</title>
</head>

<body onLoad="<%=onLoadString%>">

<div id="light" class="white_content"><iframe frameborder="0" src="http://www.domain.com/message.txt" width="100%" height="300">
</iframe> <a href = "javascript:void(0)" onclick = "document.getElementById('light').style.display='none';document.getElementById('fade').style.display='none'">Close</a></div>
<div id="fade" class="black_overlay"></div>

</body>
</html>

Answer : execute onLoad only once in an ASP page

Hi again rastafaray, you can do this with sessions. Here's a code snippet (below).

/ Tobzzz
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
<%
If session("alreadyLoaded") = false then
	Set fso = CreateObject("Scripting.FileSystemObject") 
	If (fso.FileExists("C:\inetpub\message.txt"))=true then
		onLoadString = "document.getElementById('light').style.display='block';document.getElementById('fade').style.display='block';"
	Else
		onLoadString = ""
	End If
	Set fso = Nothing
	session("alreadyLoaded") = true
End If
%>
Random Solutions  
 
programming4us programming4us