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

[Solved] Best way to detect page is in a radWindow

3 Answers 201 Views
Window
This is a migrated thread and some comments may be shown as answers.
Randy
Top achievements
Rank 1
Randy asked on 12 Feb 2009, 02:44 PM
I'm looking for a javascript logic that I can use to detect if the page is in a RadWindow or not.  The main reason is that I need to call the radWindow.close() when inside a RadWindow or self.close() when in just a regular browser window.  How best to handle this?

Also,  keep in mind that the parent page that launched the window may not have any Telerik content.  We have an application that has two modes:   Normal (with Telerik Controls) and 508 (which does not have any Telerik controls).

Randy

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 12 Feb 2009, 03:16 PM
Hello Randy,

I would suggest to use the GetRadWindow() function:
function GetRadWindow() 
  var oWindow = null
  if (window.radWindow) 
     oWindow = window.radWindow; 
  else if (window.frameElement.radWindow) 
     oWindow = window.frameElement.radWindow; 
  return oWindow; 



Sincerely yours,
Georgi Tunev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Tigerman
Top achievements
Rank 1
answered on 20 Dec 2009, 02:19 AM
The only problem with the standard code is that is never returns from the GetRadWindow Function as currently stated, however a minor rewrite works in both normal and radwindows.

function GetRadWindow() 
var radWin = null
if (window.radWindow) 
radWin = window.radWindow; 
else if (window.frameElement != null && window.frameElement.radWindow) 
radWin = window.frameElement.radWindow; 
return radWin 
 

The problem is caused because the frameElement is not defined in a normal page.
0
Georgi Tunev
Telerik team
answered on 21 Dec 2009, 07:43 AM
Hi Tigerman,

Yes - you are right. Thank you for sharing your code with us.


Sincerely yours,
Georgi Tunev
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.
Tags
Window
Asked by
Randy
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Tigerman
Top achievements
Rank 1
Share this question
or