ASP.NET TidbiTIP #3

HOWTO: Cause a page to escape any frames it may be embedded within

/// <summary>
/// If the page is loaded inside a frame,
/// calling this method will cause the page to leave the frame and load by itself.
/// </summary>
/// <remarks>Has not been tested on browsers other than IE5+</remarks>
public void EscapeFrame()
{
    
RegisterStartupScript("escapeFrame",
         
"<script language='javascript'>if(window.top!=self)window.top.location.replace(self.location);</script>");
}

No Comments