我想在进入网站时自动打开一个fancybox,并且txt文件中读取的值为“1”
fancybox 的内容将成为另一个页面的 iframe(alert.php)
要读取 txt 的值,我有这个
<?php
$line = file('alert.txt');
$valrec= $line[0]; //if "1" the fancybox appear
?>
我在使用所读内容时遇到困难。
已经看过
最佳答案
补充之前的答案,您可以这样做:
<?php
$line = file('alert.txt');
$valrec = $line[0]; //if "1" the fancybox appear
if($valrec == 1){
?>
<script type="text/javascript">
jQuery(document).ready(function($){
$.fancybox({
href: "alert.php",
type: "iframe"
});
}); //ready
</script>
<?php
}; // closes if
?>
关于javascript - 在条件后打开 fancybox,并在 .txt 文件中读取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23796418/