简体   繁体   中英

How to close aspx page that is redirect from handler

I am in critical situation. In my application I try to close opened window using javascript function.

function Close_Window() {
            var myWin = window.open('', '_parent', '');
            myWin.close();
        }

this function is used in 3 aspx pages. That page will open from mail means my application is used for sending Mail. In that such as normal newsletter there will be three footer links like UnSubscribe,Forward A Friend,Change E-Mail address.

So on click of close button for above these three pages I had written that code. The page will be opened from “ashx” file. And I try to close it using Javascript. So close button is working when I direct click on the above three links.

But by right clicking on that I open it in new window or new tab close button is not working.

So please give me solution that how can I close aspx page using javascript or in code behind.

My purpose is page should be close any how by javascript or by code behind.

Note : I am opening that page using ashx handler.

If you want total control of opening and closing windows, keep the control and do not transfer the control to the browser. The behaviour of Html is well defined by W3C. The behaviour of new browser windows/tabs will vary between different browsers, and probably in the future.

Why do you open and close a page directly?

\n

Probably you want to execute a GET request on the server to trigger some action. Take a look at the jQuery get method. So you can execute your request, without the need to open/close a new page.

If you want the user to make a choice, after clicking the link, I would work with a jQuery modal dialog . This pops up a dialog, but inside the current HTML page. Therefor you are in control of closing the dialog.

If you open a new window/tab the browser is in control, and the behaviour depends on the browser / user settings combination.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM