Why is the chat window opening before I click open chat?

So, initally, I had no issues. It seemed to be working fine. I load the script and it was giving just the ‘open chat’ option.

Now, it loads the whole chat window already open, but not the content page of the chat. I have to click ‘exit chat’ and ‘open chat’ for it to actually open up the content.

I don’t want the content window to even open until I click ‘open chat’.

(for the sake of ease, I left the css as a style tag in the webpage for now. Typically, I have a stylesheet href in the head)

HTML

<!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <style>
#forumWindow {
    padding: 10px;
    height: 350px;
    width: 250px;
    opacity:0.9;
    filter:alpha(opacity=50);
    -moz-border-radius: 20px 20px 20px 20px; 
    -webkit-border-radius: 20px 20px 20px 20px;
    border: 1px #000 dotted
    z-index: 1000;
        }
    .button { background:url('https://www.haikimura.com/images/b.png');
    -moz-border-radius: 1em;
    -webkit-border-radius: 1em; 
    z-index:4; 
    border-radius: 1em; 
    border:1px dotted #FFF0F5; 
    font-family: Garamond; 
    color: #fff; 
    font-size: 15px; }

     .box { 
    position: fixed; 
    bottom: 5px; 
    right: 40px; 
    width: 250px; 
    padding: 0px; 
    text-align: center; 
    cursor: default;
    background:url('https://www.haikimura.com/images/b.png') repeat; opacity:.80; 
    border:1px dotted #FFF0F5; 
    color: #fff; 
    font-family: Garamond; 
    font-size: 15px; 
    border-radius:5px; }

    .prettyFrame { 
    width: 100%; 
    height: 90%; 
    -moz-border-radius: 20px 20px 20px 20px; 
    -webkit-border-radius: 20px 20px 20px 20px; 
    border: none; }
</style>
    </head>
    <body>

    <button id="openForumBtn" class="box">open chat</button>
   
   
    <div id="overlay"></div>
    <div id="forumWindow" class="box">
    <iframe id="forumFrame" src="" class="prettyFrame"></iframe>
    <button id="closeForumBtn" class="button">exit chat</button>
    </div> 

<script>
document.getElementById('openForumBtn').addEventListener('click', function() {
    document.getElementById('forumWindow').style.display = 'block';
    document.getElementById('forumFrame').src = 'https://www.haikimura.com/'; // Replace with your forum URL
    });

    document.getElementById('closeForumBtn').addEventListener('click', function () {
    document.getElementById('forumWindow').style.display = 'none';
    document.getElementById('forumFrame').src = '';
    }); 
</script>

    </body>
    </html>

css

#forumWindow {
    padding: 10px;
    height: 350px;
    width: 250px;
    opacity:0.9;
    filter:alpha(opacity=50);
    -moz-border-radius: 20px 20px 20px 20px; 
    -webkit-border-radius: 20px 20px 20px 20px;
    border: 1px #000 dotted
    z-index: 1000;
        }
    .button { background:url('https://www.haikimura.com/images/b.png');
    -moz-border-radius: 1em;
    -webkit-border-radius: 1em; 
    z-index:4; 
    border-radius: 1em; 
    border:1px dotted #FFF0F5; 
    font-family: Garamond; 
    color: #fff; 
    font-size: 15px; }

     .box { 
    position: fixed; 
    bottom: 5px; 
    right: 40px; 
    width: 250px; 
    padding: 0px; 
    text-align: center; 
    cursor: default;
    background:url('https://www.haikimura.com/images/b.png') repeat; opacity:.80; 
    border:1px dotted #FFF0F5; 
    color: #fff; 
    font-family: Garamond; 
    font-size: 15px; 
    border-radius:5px; }

    .prettyFrame { 
    width: 100%; 
    height: 90%; 
    -moz-border-radius: 20px 20px 20px 20px; 
    -webkit-border-radius: 20px 20px 20px 20px; 
    border: none; }

js

document.getElementById('openForumBtn').addEventListener('click', function() {
    document.getElementById('forumWindow').style.display = 'block';
    document.getElementById('forumFrame').src = 'https://www.haikimura.com/'; 
    });

    document.getElementById('closeForumBtn').addEventListener('click', function () {
    document.getElementById('forumWindow').style.display = 'none';
    document.getElementById('forumFrame').src = '';
    }); 

New contributor

Alyssa Dunn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Add display: none to #forumWindow as an initial value would solve your problem

#forumWindow {
 padding: 10px;
 height: 350px;
 width: 250px;
 opacity:0.9;
 filter:alpha(opacity=50);
 -moz-border-radius: 20px 20px 20px 20px; 
 -webkit-border-radius: 20px 20px 20px 20px;
 border: 1px #000 dotted
 z-index: 1000;
 display: none; // here
}

New contributor

Ibnu Alinsani is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật