Click here to Skip to main content
14,733,890 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi,

I have an issue in my asp.net application.

In my web application i used window.showModalDialog(url, arg) to show popup. According to my architecture One popup shows another popup that show another popup and so on.

My aim is to redirect when session is getting timed out. So if i am in 5th popup of a page i have to close all 5 popup and should redirect my parent(Home.aspx) to login.aspx.

Please help me as soon as possible.
Thanks in advance.
Posted
Comments
Richard Deeming 1-Dec-14 10:41am
   
showModalDialog is deprecated in Firefox[^], and disabled in Chrome[^].
Dhaneshmon 1-Dec-14 10:43am
   
My application is focusing on IE9 and IE 10.

1 solution

Hi Dhanesh,

I have simulated your requirement using two html files.

1.html-
<html>
	<head>
 	<script>
	var counter = 0;
		function showDialogs()
		{
			returnVal = window.showModalDialog("index.html",{ counter : counter , obj : window}, "dialogWidth:350px;dialogHeight:250px;center:yes;status:false;help:false;resizable:false;scroll:false");
			alert('Reset the window href now');
		}
     
	</script>
 </head>
	<body>
		<input type="button" value="Show" onclick="showDialogs();" />
	</body>
</html>



Now the second html.
index.html-
<html>
	<head>
	<script>
		function load(){
			
			parentWindow = window.dialogArguments;
			
			parentWindow.counter = parentWindow.counter +1;
			if(window.dialogArguments.counter < 4){
			document.getElementById('lbl').innerHTML = window.dialogArguments.counter;
				returnVal = window.showModalDialog("index.html", {counter : parentWindow.counter , obj : parentWindow.obj},"dialogWidth:350px;dialogHeight:250px;center:yes;status:false;help:false;resizable:false;scroll:false");
				setTimeout(function(){window.close()}, 2000);
			} else {
			    //Else part will be executed on the last popup
				setTimeout(function(){alert('Session Timeout. Closing everything');window.close()}, 1000);
			}
		}
		</script>
 	
 </head>
	<body onload="load()">
	child window<label id="lbl"> </label>
		
	</body>
</html>



Open the 1st html page. It will open 4 popups now. The last popup will have a simulation for timeout, which will trigger the close event for all the windows opened in the stack.

Thanks
Srikant
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900