how to make such a thing in javascripte + php
<script> function fight(){ <?php if($row['fight'] == 1){ echo "setTimeout(function(){ location.href=''; }, 1000);"; } else{ } ?> } </script> how to make such a thing in javascripte + php
<script> function fight(){ <?php if($row['fight'] == 1){ echo "setTimeout(function(){ location.href=''; }, 1000);"; } else{ } ?> } </script> I would do this:
<script> if ( '<?=$row['fight']?>' == 1 ) fight = Function.prototype; else { fight = function (){ setTimeout( function(){ location.href=''; }, 1000); } } </script> But rather:
<script> fightFlag = <?=( $row['fight'] != 1 )?>; fight = ( fightFlag ? Function.prototype : function (){ setTimeout( "location.href = '';", 1000); } ); </script> <script> function fight(){ if (<?php echo $row['fight']; ?> == 1 { setTimeout(function(){ document.location='/'; }, 1000); } } </script> Source: https://ru.stackoverflow.com/questions/75783/
All Articles
$row['fight'] != 1, or change thelocation.href='';for something more real. Or atlocation.reload();. - ling