Link to home
Start Free TrialLog in
Avatar of rastafaray
rastafarayFlag for United States of America

asked on

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:


<%@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>

Open in new window

Avatar of Jonah11
Jonah11

What's happening now?  by default onLoad only executes one time per each page load.....
ASKER CERTIFIED SOLUTION
Avatar of tobzzz
tobzzz
Flag of Spain image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mark Franz
Or write a cookie to store the set bit.  Although neither way is foolproof...
Avatar of rastafaray

ASKER

ty tobzzz looks great.  i will give it a try.