Click here to Skip to main content
Click here to Skip to main content

Custom error page loading inside an iframe

, 11 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Hello all,When we use Custom error pages in our website, and when we load our pages inside iframes, if an error occurs the custom error page loads

Editorial Note

This articles was originally at wiki.asp.net but has now been given a new home on CodeProject. Editing rights for this article has been set at Bronze or above, so please go in and edit and update this article to keep it fresh and relevant.

Hello all,

When we use Custom error pages in our website, and when we load our pages inside iframes, if an error occurs the custom error page loads inside that iframe. Sometimes it breakups the site uniformity and there are times we need to display the custom error page as it is (Not load it inside the iframe). There is an easy way to do this. By having the following javascript/jQuery code within the custom error page head section, it will check whether it's loading inside an iframe. If it's loading inside an iframe, then the custom error page will set as the top page.

    <script>

        $(function () {

            if (window != window.top) { //Checks whether the custom error page is loading inside an iframe

                window.top.location = window.location; //Set the top location to custom error page location

            }

        });

    </script>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

ASP.NET Community

United States United States
The ASP.NET Wiki was started by Scott Hanselman in February of 2008. The idea is that folks spend a lot of time trolling the blogs, googlinglive-searching for answers to common "How To" questions. There's piles of fantastic community-created and MSFT-created content out there, but if it's not found by a search engine and the right combination of keywords, it's often lost.
 
The ASP.NET Wiki articles moved to CodeProject in October 2013 and will live on, loved, protected and updated by the community.
Group type: Collaborative Group

411 members


Comments and Discussions

 
QuestionHow would this be applied to a DNN page? PinmemberMember 1055853118-Mar-14 7:40 
AnswerRe: How would this be applied to a DNN page? PinmemberMember 1055853118-Mar-14 7:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411022.1 | Last Updated 11 Oct 2013
Article Copyright 2013 by ASP.NET Community
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid