gpt4 book ai didi

我的聊天框的最小化和关闭按钮的 JavaScript 不起作用

转载 作者:行者123 更新时间:2023-12-03 05:25:34 25 4
gpt4 key购买 nike

我正在为我的邮件聊天机器人设计一个聊天框。我对网页设计和 JavaScript 知之甚少。我无法最小化或关闭我的聊天框。我尝试从各个站点复制该函数的多个 .js 代码,但没有一个有效。

<html>
<head>
<title>chatbox for bot</title>
</head>
<style>
.popup-wrapper {
position: fixed;
background-color: #FFFFFF;
right: 50px;
bottom: 0px;
padding: 0px;
height: 410px;
width: 250px;
z-index: 200;
-moz-border-radius:10px 10px 0px 0px;
border-radius:10px 10px 0px 0px;
}

.popup-header {
background-color: #5b6fc7;
color: #ffffff;
height: 10%;
padding: 10px 10px 5px 10px;
-moz-border-radius:10px 10px 0px 0px;
border-radius:10px 10px 0px 0px;

}

.popup-tab {
position: fixed;
right: 50px;
bottom: 0px;
padding: 10px 10px 5px 10px;
background-color: #5b6fc7;
height: 40px;
width: 250px;
z-index: 200;
cursor: pointer;
-moz-border-radius:10px 10px 0px 0px;
border-radius:10px 10px 0px 0px;
color: #ffffff;
}

.botMessage {
background-color: #eeeeee;
position: relative;
padding: 5px;
margin: 5px;
display: inline-block;
-moz-border-radius:10px 10px 10px 10px;
border-radius:10px 10px 10px 10px;
}

.humanMessage {
background-color: #5b6fc7;
position: relative;
color: #FFF;
padding: 5px;
margin: 5px;
display: inline-block;
float: right;
-moz-border-radius:10px 10px 10px 10px;
border-radius:10px 10px 10px 10px;
}


.close-chat, .minimize-chat {
cursor: pointer;
margin-right: 5px;
float: right !important;
}

.convo {
height: 320px;
padding: 5px;
border-style: solid;
border-width: 1px;
border-color: #eeeeee;
}

.chatlog {
width: 750px;
height: 300px;
padding: 5px;
border: 1px solid #000000;
}

.scroll {
overflow-y: auto;
overflow-x: hidden;
}

.agentMessage {
background-color: #5cb85c;
position: relative;
padding: 5px;
margin: 5px;
display: inline-block;
-moz-border-radius:10px 10px 10px 10px;
border-radius:10px 10px 10px 10px;
}

form#talkform {
width
height: 50px;
padding: 10px 10px 5px 10px;
-moz-border-radius:10px 10px 10px 10px;
border-radius:10px 10px 10px 10px;



/*
.say something {
width: 0px;
border-color: #ffffff;
border-style: solid;
}
*/

}
.hidden {
display: none !important;
visibility: hidden !important;
}
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
box-sizing: border-box;
}

#popup-WrapperClose {
width: 15px;
height: 15px;
z-index: 12;
border-radius: 50%;
background-color: red;
position: absolute;
top: 15px;
right: 15px;
}

#popup-WrapperMini {
width: 15px;
height: 15px;
z-index: 12;
border-radius: 50%;
background-color: green;
position: absolute;
top: 15px;
right: 45px;
}

img {
display: block;
margin: 80px auto -60px auto;
}
</style>
<body>
<div class="popup-wrapper">
<div class="popup-header">
<b>
Talk to
<span class="botname">Ella</span>
</b>
<input id="popup-WrapperClose" type="button" onclick="windowClose();"></input>
<input id="popup-WrapperMini" type="button" onclick="windowMin();"></input>
</div>
<div class="popup-chat">
<div class="response hidden"></div>
<div class="convo scroll">
<div class="humanMessage">
<div class="usersay">&nbsp;</div>
</div>
<br></br>
<div class="botMessage">
<div class="ella">
<div class="botsay"></div>
</div>
</div>
<br></br>
</div>
<form method="post" name="talkform" id="talkform" action="index.php">
<form id="talkform" class="talkform">
<input id="say" name="say" placeholder="say something" type="text">
<input id="say-button" class="say-button" name="say-button" value="say" type="submit">
</form>
</form>
</div>
</div>

<script>
$('#popup-wrapperClose').click( function() {
$("#popup-wrapper").hide(300);
});

$('#popup-wrapperMini').click( function() {
if (minimize === false) {
$("#popup-wrapperMini").hide();
$('#popup-wrapper').css('display','block');
minimize = true;
} else {
$("#popup-wrapper").show();
$('#popup-wrapper').css('display','none');
minimize = false;
}
});
return false;
});
</script>
</body>
</html>

最佳答案

您的代码中有一些地方需要纠正:

1) 在您的 Jquery 代码中,您使用的是 id 选择器 (#),并且没有使用 <div>有 id。

2)您为最小化和关闭按钮使用了错误的类名:

在 HTML 中:

popup-WrapperMini

在 JS 中:

popup-wrapperMini

3)在 javascript 中,您正在使用 var 最小化,但您是它来自吗?

我用最小化和紧密工作制作了一个 JSFiddle。请看一下: https://jsfiddle.net/dudu84/ue0c94q7/1/

希望对你有帮助!

关于我的聊天框的最小化和关闭按钮的 JavaScript 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41155246/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com