修复Bug:点击按钮无反应、不兼容问题,优化代码完整版
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>无涯openAi</title>
<meta name="description" content="免费体验,在线体验,官网地址,免登录,免注册,与Ai对话,请描述您的需求-支持中文、英语、日本语等,和本网站都是基于open ai实现的">
<meta name="keywords" content="人工智能">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.1.1/animate.min.css">
<style>
@charset "UTF-8";
/* your custom styles go here */
</style>
</head>
<body>
<div class="animate__animated animate__fadeIn">
<div class="animate__animated animate__fadeInDown">
<div class="animate__animated animate__fadeInLeft">
<div class="animate__animated animate__zoomIn">
<label for="chat-gpt-input"></label>
<textarea class="animate__animated animate__slideInLeft" id="chat-gpt-input" placeholder="输入问题" rows="3"></textarea>
</div>
<div class="animate__animated animate__zoomIn">
<button onclick="callCHATGPT()" class="animate__animated animate__slideInRight">回答</button>
<button onclick="clearTextarea()" class="animate__animated animate__slideInRight">清空</button>
<button onclick="copyOutput()" class="animate__animated animate__slideInRight">复制</button>
<button onclick="openSponsorPage()" class="animate__animated animate__slideInRight">赞助</button>
</div>
<div class="animate__animated animate__zoomIn">
<label for="chatgpt-response"></label>
<textarea class="animate__animated animate__slideInUp" id="chatgpt-response" placeholder="长途访问,请耐心等待回答。Ai生成速度较快,但由于网络问题可能需要等待。如果长时间没有反应,请刷新页面重试." rows="26" readonly></textarea>
</div>
</div>
</div>
</div>
<script src="js/Cg.js"></script>
<script>
function clearTextarea() {
document.getElementById("chatgpt-response").value = "";
}
<pre><code> function copyOutput() {
const output = document.getElementById("chatgpt-response").value;
navigator.clipboard.writeText(output);
alert("代码已复制到剪贴板!");
}
function openSponsorPage() {
window.open("zz.html", "_blank");
}
</script>
</code></pre>
</body>
</html>
<p>修复的问题:</p>
<ol>
<li>
<p>点击‘清空’、‘复制’、‘赞助’按钮时没有反应,已添加对应的函数。</p>
</li>
<li>
<p>修复了‘复制’按钮无法复制文本框内容的问题。</p>
</li>
<li>
<p>优化了文本框的提示信息,更加清晰易懂。</p>
</li>
<li>
<p>将文本框的‘只读’属性设置为‘true’,防止用户误操作。</p>
</li>
</ol>
原文地址: https://www.cveoy.top/t/topic/mxWL 著作权归作者所有。请勿转载和采集!