Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

    /// <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>

Posted on Friday, March 19, 2010 6:34 AM ASP.NET , CSS/DHTML/JavaScript | Back to top


Comments on this post: JavaScript function to Redirect parent of IFrame to specified URL

# re: JavaScript function to Redirect parent of IFrame to specified URL
Requesting Gravatar...
Thanks for the code! I look forward to giving it a try.
Left by Sonja Kathryna on Jun 02, 2011 3:55 PM

# re: JavaScript function to Redirect parent of IFrame to specified URL
Requesting Gravatar...
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);
}
Left by xcv xvx on Jan 07, 2012 7:02 PM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net