我有一个嵌入视频,我只想允许登录用户查看它。
如果用户未登录并尝试玩游戏,则必须记录警报
我尝试以下方法,但它不起作用:
<div id="container">
<embed id="playerid" width="300" height="200" flashvars="file=http://www.mydomain.com/Video/demo.flv&autostart=false&stretching=fill&image=http://www.mydomain.com/Video/demo.jpg&logo=http://www.mydomain.com/Video/Watermark.gif" allowscriptaccess="always" allowfullscreen="true" quality="high" bgcolor="#330099" name="ply" id="ply" style="undefined" src="player.swf" type="application/x-shockwave-flash">
</div>
我的 jQuery 代码是
<script>
<?php
if(!$login){
?>
$(document).ready(function(){
$('#container').click(function(){
alert('video clicked');
});
});
<?php
}
?>
</script>
最佳答案
试试这个:
<?php $login = true; //Let's make it true just for testing ?>
<script>
$(document).ready(function(){
$('#container').click(function(){
if("<?php echo($login); ?>"){
alert('Play Video');
}else{
alert("Please login to play video");
}
});
</script>
关于javascript - 使用 jquery 控制嵌入视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24012719/