<script type="text/javascript" > function pageopen() { var Hid = document.getElementById('HiddenFieldCity'); var HidA = document.getElementById('HiddenFieldArea'); var HidC = document.getElementById('HiddenFieldComm'); var HidD = document.getElementById('txtDate'); if (document.getElementById('ddlone').value=="Select Here") { alert("Please Select City"); return false; } window.open('Home.aspx?hid=' + Hid.value + '& HidA=' + HidA.value + '& HidC=' + HidC.value + '& HidD=' + HidD.value + '',"Welcome","titlebar=0,fullscreen=0,addressbar=0,left=0,top=0,maximized=yes,width=1024,height=700,scrollbars=no,resizable=yes") window.close("index.aspx"); }
<a href="" onclick="CloseWindow();">Close Window</a>
<script language=javascript> function CloseWindow() { window.open('','_self',''); window.close(); } </script>
Quote:Your JavaScript code can only close a window without confirmation that was previously opened by window.open(). This is an intentional security precaution because a script running on a webpage does not own the window, and by closing it discards the browsing history in that window. The workaround is to either have a "welcome page" or otherwise some sort of page that pops up the window you want to close with window.open in the first place, or to tell your users to modify their browser security settings to allow your application to close their windows.
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)