I want to create a link on the Web page that closes the current active tab in the browser without closing the other tabs in the browser. When the user clicks the close link, a prompt message appears asking the user to confirm with "YES" and "NO" two buttons. If the user clicks Yes, closes the page and, if no, does nothing.
How to do it? Do you have any suggestions?
You will need to use JavaScript to do this. OA Credit Disk Two-sided disk source building bbs.yasewl.com Please add link description use Window.close () method
Close ();
Note: The current label is implied. This is equivalent to:
Window.close ();
Or you can specify a different window.
Such as:
function Close_window () {
if (Confirm ("Close Window?")) {
Close ();
}
}
Html:
<a href= "Javascript:close_window (); >close</a>
Or:
<a href= "#" onclick= "Close_window (); return false;" >close</a>
return false here to prevent the default behavior of the event. Otherwise, the browser jumps to that URL.
Now the options on the Window.confirm () dialog box will be OK and cancel (not and no). If you do need yes and no, you need to create a JavaScript dialog box for a pattern.
Note: There are different browser differences than the above. If you use JavaScript (via window.open ()) To open the window, you can close the window with JavaScript. Firefox does not allow you to close other windows. I believe IE will ask the user to confirm. Other browsers may vary.
OA Credit Disk Two-sided disk source building step JS How to close the current browser window