網頁載入後, 將自己網頁關閉, 使用Javascript
網頁載入後, 將自己網頁關閉, 使用Javascript
HTML+Javascript
<script>
//window.close(); //會顯示詢問訊息
//利用執行自己, 達到javascript關閉自已(不會顯示詢問訊息)。
//第二次執行因為有傳參數, 後端判斷不執行
window.onload = function () {
open(location + 'is_close=Y', '_self').close();
};
</script>
Server Side (C#, MVC Action)
public ActionResult ServerAction(string is_close)
{
//直接結束作業
if (is_close == "Y")
{
return View();
}
//要執行的CODE
}
測試使用IE和Edge有效
留言
張貼留言