Home / ASP.NET Wiki / Javascript / Javascript libraries / jQuery / Custom error page loading inside an iframe

Custom error page loading inside an iframe

 Rate It (1)

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>

Revision number 1, Thursday, May 17, 2012 4:54:14 PM by ruchira

Comments

Shortcuts

Table of Contents

Top Wiki Contributors

(last 30 days)

  1. abiruban (1)