This is a migrated thread and some comments may be shown as answers.

Close window with timer in content

2 Answers 228 Views
Window
This is a migrated thread and some comments may be shown as answers.
Clive Hoggar
Top achievements
Rank 1
Clive Hoggar asked on 19 Dec 2009, 02:45 PM
Hi
I am having trouble getting this to close the window after a time delay, from within the window content.
Can't see what i am doing wrong. Can anyone help?
Thanks
Clive
<head runat="server">  
    <title>Untitled Page</title> 
<script type="text/javascript">  
function closeWindow()     
{     
    var oWindow = GetRadWindow();     
    oWindow.close();     
}     
function GetRadWindow()        
{     
  var oWindow = null;     
  if (window.radWindow)     
     oWindow = window.radWindow;     
  else if (window.frameElement.radWindow)     
     oWindow = window.frameElement.radWindow;     
  return oWindow;     
}       
</script>    
 
</head> 
<body onload="setTimeout(closeWindow(), 3000);">  
    <form id="form1" runat="server">  
    <div> 
      
        Close this window after downloading your file if it does not close automatically</div> 
    </form> 

2 Answers, 1 is accepted

Sort by
0
Svetlina Anati
Telerik team
answered on 19 Dec 2009, 03:29 PM
Hello Clive,

When you want to use a function with its name with the setTimeout javascript function, you should put it in quotes as shown below:

<head id="Head1" runat="server">
    <title>Untitled Page</title>
  
    <script type="text/javascript">   
function closeWindow()      
{      
    var oWindow = GetRadWindow();      
    oWindow.close();      
}      
function GetRadWindow()         
{      
  var oWindow = null;      
  if (window.radWindow)      
     oWindow = window.radWindow;      
  else if (window.frameElement.radWindow)      
     oWindow = window.frameElement.radWindow;      
  return oWindow;      
}        
    </script>
  
</head>
<body onload="setTimeout('closeWindow()', 3000);">
    <form id="form1" runat="server">
    <div>
        Close this window after downloading your file if it does not close automatically</div>
    </form>
</body>
</html>

Once I did this, everything started working as expected and the RadWindow was closed as expected.

Best wishes,
Svetlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Clive Hoggar
Top achievements
Rank 1
answered on 19 Dec 2009, 04:43 PM
Doh!

Thanks for your help.

Clive
Tags
Window
Asked by
Clive Hoggar
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Clive Hoggar
Top achievements
Rank 1
Share this question
or