Click here to Skip to main content
15,444,490 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I need a javascript code execute a aspx page_load event without open a new window.

Thanks in advance.

You can use a ajax get to load a page without any windows popping up.

Easy with jQuery:

$.get('WebForm1.aspx', function(data) {
   // Don't have to do anything. Page is loaded..
Share this answer
jeyamothi 17-Jul-12 7:11am    
i need only javascript code.
StianSandberg 17-Jul-12 7:22am    
It's not possible to call Page_Load from javascript without loading the way i showed you.
jeyamothi 17-Jul-12 7:45am    
it's not working i missed any thing advice me

Actually i want to expire the session at the time of browser close.

Finally i got a solution

<script language="javascript" type="text/javascript">

    var clicked = false;
    function CheckBrowser() {
        if (clicked == false) {
            //Browser closed
        else {
            clicked = false;

    function bodyUnload() {
        if (clicked == false)//browser is closed
            //var request = GetRequest();
            //location.href = 'LogOut.aspx';
            var request = GetRequest();

  "GET", "LogOut.aspx", true);
    function GetRequest() {
        var request = null;
        if (window.XMLHttpRequest) {
            //incase of IE7,FF, Opera and Safari browser
            request = new XMLHttpRequest();
        else {
            //for old browser like IE 6.x and IE 5.x
            request = new ActiveXObject('MSXML2.XMLHTTP.3.0');
        return request;


<body onunload="bodyUnload();" onclick="clicked=true;">
    <form id="form1" runat="server">
Share this answer
StianSandberg 18-Jul-12 9:51am    
this is the exact same as I showed you in my answer, just a hell lot more code..

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900