jQuery( document ).ready(function( $ ) { url = parent.document.URL; var div = document.createElement('div'); div.setAttribute('id', 'chat_widget_wrap'); div.style.height = "auto"; var iframe = document.createElement('iframe'); iframe.setAttribute('id', 'customer-chatbox'); iframe.setAttribute("src", "https://chat.unitybankng.com/widget_content?url="+url); iframe.style.position = "fixed"; iframe.style.zIndex = 999999; iframe.style.bottom = "-60px"; iframe.style.right = "10px"; iframe.style.width = "300px"; iframe.style.height = "350px"; div.style.right = 0; div.style.marginRight = '10px'; iframe.style.bottom = 0; iframe.border = 0; iframe.marginwidth = 0; iframe.marginWidth = 0; iframe.marginheight = 0; iframe.marginHeight = 0; iframe.frameBorder = 0; document.body.appendChild(div); document.getElementById("chat_widget_wrap").classList.add('reduce-box'); document.getElementById("chat_widget_wrap").appendChild(iframe); var responsive_width = "768"; $(window).on('load resize', function(e) { if($(window).width() <= responsive_width){ var x = document.getElementById("customer-chatbox"); $(x).css("width","100%"); $(x).css("margin-right","0px"); $(x).css("height","100%"); x.contentWindow.postMessage('responsive', '*'); }else{ var x = document.getElementById("customer-chatbox"); $(x).css("bottom","-60px"); $(x).css("width","300px"); $(x).css("margin-right","5px"); $(x).css("height","350px"); x.contentWindow.postMessage('desktop', '*'); } }); });