function toggleVisibility(object) { var myObj = document.getElementById(object); // alert("myobject is " + myObj); var visib = myObj.style.display; // alert("myobject attribute is " + visib); if (myObj.style.display == 'none'){ myObj.style.display = "block"; } else { myObj.style.display = "none"; } } // function toggleVisibility(object) { // alert("alert called on obj=" + object) // } var style = document.createElement('style'); style.innerHTML = '.oc-button:active { box-shadow:1px 1px 5px black; transform: translateY(4px); background-color: #eee;} .oc-button:hover {background-color: #eee;} .tooltip .tooltiptext {visibility: hidden;position: relative; top: -40px; background-color: #834d54; padding: 7px 35px; width: max-content; display: inline-block; text-align: center; left: -29px; border-radius: 8px; font-size:1.2rem; color:white;} .tooltip:hover .tooltiptext { visibility: visible; opacity: 1;} #ifrm html {background:red;}'; window.onload = function() { document.getElementsByTagName('head')[0].appendChild(style); var ifrm = document.createElement('iframe'); ifrm.setAttribute('id', 'ifrm'); // assign an id ifrm.setAttribute('class', 'iframe_gpt'); ifrm.setAttribute("style", "position:fixed;width:400px;height: calc(100vh - 115px);max-height:760px;bottom:50px;right:10px;display:none;border:none;"); document.body.appendChild(ifrm); // to place at end of document // ifrm.setAttribute('src', 'http://localhos:4020/ask/018d8e84-625b-72a2-9a1e-b6c2c500cd31'); ifrm.setAttribute('src', 'https://oai.ymir.eu/ask/018d8e84-625b-72a2-9a1e-b6c2c500cd31'); var ocButton = document.createElement('img'); var tpImg = document.createElement('div'); tpImg.setAttribute('class', 'tooltip'); var tpText = document.createElement('span'); tpText.setAttribute("class", "tooltiptext"); tpText.innerHTML="Ymir AI"; tpImg.appendChild(tpText); ocButton.src = "https://oai.ymir.eu/resources/images/button.svg" ocButton.setAttribute('id', 'open_close_button'); ocButton.setAttribute('class', 'button is-primary'); ocButton.addEventListener('click', function(){toggleVisibility('ifrm')}); ocButton.setAttribute("style", "position:absolute;width:60px;height:60px;bottom:0px;right:0px;visibility:visible;cursor:pointer;"); ocButton.classList.add("oc-button"); tpImg.setAttribute("style", "position:fixed;width:60px;height:60px;bottom:10px;right:80px;visibility:visible;box-shadow:5px 5px 10px gray; opacity:1"); tpImg.appendChild(ocButton); document.body.appendChild(tpImg); }