JavaScript function to Redirects parent of IFrame to specified URL
Posted
by Michael Freidgeim
on Geeks with Blogs
See other posts from Geeks with Blogs
or by Michael Freidgeim
Published on Fri, 19 Mar 2010 11:34:58 GMT
Indexed on
2010/03/19
11:51 UTC
Read the original article
Hit count: 398
/// <summary>
/// Redirects parent of IFrame to specified URL
/// If current page doesn't have parent, redirect itself
/// </summary>
/// <param name="page"></param>
/// <param name="url"></param>
public static void NavigateParentToUrl(Page page, string url)
{
String script = @"
try
{
var sUrl='" + url + @"';
if (self.parent.frames.length != 0)
self.parent.location=sUrl;
else
self.location = sUrl;
}
catch (Exception) {}
";
page.ClientScript.RegisterStartupScript(TypeForClientScript(), MethodBase.GetCurrentMethod().Name, script, true);
}
/// <summary>
© Geeks with Blogs or respective owner