로그인 할 때 내가 다른 페이지로 리디렉션하려는 경우 사용자 지정 경고를 표시하고 싶습니다. 나는 이것을 가지고있다.자체적으로 호출되는 자바 스크립트 기능
<div id="contentCalendar" class="col-md-3 images_1_of_4 text-center">
<a><img onClick="show_alert();" id="rotateme" class="img-responsive img-circle center-block" src="web/images/calendaricon.png"/></a>
<h4><a href="#">Check our last events</a></h4>
</div>
<div id="myalert" class="alert alert-error">
<a href="#" class="close" data-dismiss="alert">×</a>
<strong>Error!</strong> You must be logged in to see our calendar.
</div>
<script>
$('#myalert').hide();
//What happen if you want to enter the events without loggin.
var logged_in = <?php echo ($logged_in); ?>;
function show_alert()
{
if(logged_in==true)
{
window.location="timeline.php";
}
else
{
$('#myalert').show();
}
}
</script>
Logged_in이 true이고 리디렉션 될 때 어떤 이유로 매력이 작동합니다. 하지만 메신저가 로그 아웃했을 때 버튼을 누르지 않아도 알림이 표시되지 않습니다.
아이디어가 있으십니까?
PHP에서 설정 한 값을 문자열로 읽으므로 부울 값으로 변환 해보십시오. – j08691
대개의 경우 logged_in의 값은 성공 사례에서는 사실이 아니지만 일부 진실 값 –