Issue
Is there any possibility to make a link or a button to close the current page? Like I have this:
<div id="arrows">
<a href="It works"><div id="arrow_left"></div></a>
<a href="It works too"><div id="arrow_right"></div></a>
<a href="??? =("><div id="arrow_close"></div></a>
</div>
And this if it's necessary this:
#arrow_close{
height: 7px;display: inline;float: left;width: 7px;
background: url(../i/close-20.png) no-repeat;
}
And I want to close the page with a button "close".
Solution
You can use
window.close()
or self.close()
to close the present window.
To prevent the browser from prompting the warning, you need to set the opener
property and then call the close.
<a href="JavaScript:CloseWindow();"><div id="arrow_close"></div></a>
<script type="text/javascript">
var CloseWindow = function() {
window.top.opener = null;
window.close();
}
</script>
Answered By - Mahesh Velaga