Best way to detect page is in a radWindow

4 posts, 0 answers
  1. Randy
    Randy avatar
    73 posts
    Member since:
    Oct 2007

    Posted 12 Feb 2009 Link to this post

    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
  2. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 12 Feb 2009 Link to this post

    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.
  3. Tigerman
    Tigerman avatar
    1 posts
    Member since:
    Jul 2007

    Posted 19 Dec 2009 Link to this post

    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.
  4. Georgi Tunev
    Admin
    Georgi Tunev avatar
    7207 posts

    Posted 21 Dec 2009 Link to this post

    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.
Back to Top