开发者

How to display a popup message at the time of page closing

Using ASP.Net, VB.Net

Whe开发者_如何学Gon i close or exit the page, it should show the pop up message like "page closing"

Need code help


try this:

<script language="JavaScript">
        window.onbeforeunload = confirmExit;
        function confirmExit() {
            return "You want to leave this page?";
        }
    </script>


<body onunload="event.returnValue = 'Check?';">

That's also pretty much the code that's used if you start typing an answer here and try to close or navigate away. ;-)

Here's an answer at another forum as well. http://www.hotscripts.com/forums/javascript/16890-code-showing-you-sure-you-want-navigate-away-page.html


Here is the link which can show you the sample code to show the message when the page is closed/Exited.

http://usefulscripts.wordpress.com/2007/10/16/window-onbeforeunload-javascript-code/

You can also further call the serverside methods using ajax in Javascript functions. The examples are present on the following linkS: http://www.singingeels.com/Articles/Using_Page_Methods_in_ASPNET_AJAX.aspx http://www.dotnetcurry.com/ShowArticle.aspx?ID=109&AspxAutoDetectCookieSupport=1


You can also use a jQuery popup message that fires at the time of page closing

$(window).bind("beforeunload", function() { 
    return inFormOrLink || confirm("Do you really want to close?"); 
})
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜