我想在网站的任何位置实施该功能,当用户点击Logout
按钮时,获得javascript confirm box
。
Laravel注销按钮看起来像:
<a class="dropdown-item" href="{{route('logout')}}" onclick="event.preventDefault();document.getElementById('logout-form').submit();">
<span class="text-danger">
<i class="fa fa-fw fa-sign-out"></i>Logout
</span>
</a>
答案 0 :(得分:0)
您可以使用javascript confirm()
功能。
<a class="dropdown-item" href="{{route('logout')}}" onclick="return logout(event);">
<span class="text-danger">
<i class="fa fa-fw fa-sign-out"></i>Logout
</span>
</a>
<script type="text/javascript">
function logout(event){
event.preventDefault();
var check = confirm("Do you really want to logout?");
if(check){
document.getElementById('logout-form').submit();
}
}
</script>
或强>
<a class="dropdown-item" href="{{route('logout')}}" onclick="event.preventDefault();var check = confirm("Do you really want to logout?");if(check){document.getElementById('logout-form').submit();}">
<span class="text-danger">
<i class="fa fa-fw fa-sign-out"></i>Logout
</span>
</a>