Create Remove Iframe At Time

create iframe with src in table > td#marker


        function removeIframe(){
            if(document.getElementById('notif-to-user')){
                var frame = document.getElementById("notif-to-user");
                frame.parentNode.removeChild(frame);
            }
        }

        function createIframe(){
            if(!document.getElementById('notif-to-user')){
                var ifrm = document.createElement('iframe');
                ifrm.setAttribute('id', 'notif-to-user');
                ifrm.setAttribute('src', 'http://mygoddamn.link');
                var el = document.getElementById('marker');
                el.parentNode.insertBefore(ifrm, el);
            }
        }

        window.setInterval(function(){
            var date = new Date();
            // jika lebih dari jam 12 iframe di hapus
            if(date.getHours() > 1){
                removeIframe();
            }
            // jika jam 1 lebih 1 menit iframe di buat
            if(date.getHours() === 1 && date.getMinutes() === 1){
                createIframe();
            }
            // jika jam 1 lebih 59 menit (jam 2) iframe di hapus
            if(date.getHours() === 1 && date.getMinutes() === 59){
                removeIframe();
            }
            // jalan tiap 5 detik
        }, 5000);
    
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s