我需要它進行年齡驗證,當我點擊under21年齡按鈕的fancybox-我的當前窗口應該關閉。需要關閉fancybox按鈕上的當前窗口點擊
我的代碼是這樣的:
<div style="display:none;">
<div id="age-popup">
<div style="margin: 0 auto;text-align: center;">
<h2>Welcome!</h2>
<h3>Please Verify Your Age to Enter.</h3>
<input type="button" name="age" onclick="return overage();" value="21 & Over" />
<input type="button" id="WarringMsg" name="WarringMsg" onclick="close_window()" value="Under 21" />
</div><br>
<p>Our product is not appropriates for individuals under 18 and window will be close automatically.</p>
</div>
function overage()
{
user = "verifieduser";
setCookie("username", user, 30);
jQuery.fancybox.close();
}
function close_window() {
// window.open("about:blank","_self");
// window.close();
window.open('','_self');
self.close();
}
window.close在Chrome和FF工作。
可能重複[如何關閉當前標籤頁在瀏覽器窗口?](http://stackoverflow.com/questions/2076299/how-to-close-current-tab-in-a-browser-window) – Liam