gpt4 book ai didi

单击图像时 Javascript 未运行

转载 作者:太空宇宙 更新时间:2023-11-04 00:50:39 25 4
gpt4 key购买 nike

在这里,我想在单击图像时显示一个窗口。该图像是地址簿之一,它应该出现在 div id="janela2" 中的地址簿。我希望它可以拖动和调整大小,但这里最重要的是让它工作,因为我相信 js 代码是正确的,但是当我单击图像时,地址簿不会出现。

没有运行的js代码是js的前两个函数,不知道为什么。我只放了地址簿代码,这样您就可以看到它是否仍然可以解决问题。到底是怎么回事?如何解决?

检查 codepen,因为代码段不工作

它的第一部分已经解决了。现在窗口会在点击时出现,但现在地址簿不起作用。 https://codepen.io/Fropis/pen/mYydYd有新代码,但现在地址簿无法使用。为什么?

https://codepen.io/Fropis/pen/XwJWjg

/**************************************** Contactos **********************************************************/
function openAB(){
document.getElementById("janela2").innerHTML = document.getElementById("mydiv").innerHTML;
}

function fechar(){
document.getElementById("janela2").innerHTML = "";
}

/*****************************THE ONE THAT MATTERS IS ABOVE****************/

html, body {
width: 3779.527559055px;
height: 100%;
font-family: "Helvetica Neue", Helvetica, sans-serif;
color: #444;
-webkit-font-smoothing: antialiased;
background-image: url("https://images4.alphacoders.com/111/111298.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: 350% 100%;
font-family: Arial, Helvetica, sans-serif;
}

/* Place the navbar at the bottom of the page, and make it stick */
.navbar {
background-color: none;
left: 30%;
position: absolute;
bottom: 0;
height: 500px;
width: 1500px;
margin-left: auto;
margin-right: auto;
padding-left: 10%;
padding-right: 10%;
border-top-right-radius: 30px;
border-top-left-radius: 30px;
text-align: center;
overflow: hidden;
}

#NetImg, #Home, #contact{
width: 400px;
height: 400px;
padding:20px;
background: none;
}

.panel {
background: #fafafa;
padding: 1em;
width: 92.5%;
margin: auto;
max-width: 30em;
}
input {
width: 100%;
box-sizing: border-box;
font-size: 1em;
margin-top: 0.5em;
padding: 0.5em;
}
input:focus {
outline: none;
}
input::after {
width: 100%;
height: 10px;
background: red;
}
.nav-list {
width: 92.5%;
max-width: 30em;
text-align: center;
margin: auto;
}
.nav-list li {
list-style: none;
display: inline-block;
background: white;
padding: 0.7em;
margin: 0 0.1em;
}
.nav-list .active {
background-color: black;
}

#janela2{
position: absolute;
width:1900px;
height:1500px;
left:1500px;
top:550px;
border-radius:20px black solid;
}
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="cale.css">
</head>
<body>
<div id="janela2">OLA</div>

<div id="mydiv" style="display:none;">
<div id="navigation">
<ul class="nav-list">
<li id="js-show-all">Mostrar Todos</li>
<li id="js-search">Procurar</li>
<li id="js-add-new">Adicionar Contacto</li>
</ul>
</div>
<div id="search-panel" class="panel">
<h1>Procurar Contacto</h1>
<form id="search" action="#">
<div id="results"></div>
<div>
<label>
<input type="text" name="search" id="search" placeholder="Insira nome do contacto" />
</label>
</div>
<input type="submit" value="Procurar"/>
</form>
</div>
<div id="contact-panel" class="panel">
<form id="contact" action="#">
<h1>Adicionar Novo Contacto</h1>
<div>
<label>
<input type="text" name="person" id="name" placeholder="Jos&eacute Bigodes" required/>
</label>
<label>
<input type="text" name="phone" id="name" placeholder="912942923" maxlength="9" pattern=".{9,}" required title="Insira 9 caracteres"/>
</label>
<label>
<input type="email" name="email" id="name" placeholder="nome@desk.com" pattern="+@desk.com" required/>
</label>
</div>
<div>
<input type="submit" value="Adicionar" />
</div>
</form>
</div>
<div id = "show-panel" class="panel">
</div>
</div>
<div class="navbar">
<a><img onclick="openAb()" src="http://downloadicons.net/sites/default/files/address-book-icon-62889.png" id="contact"></a>
</div>
</body>
<script src=cale.js></script>
</html>

最佳答案

openAb 在 html 与 openAB 函数在 js 中有错字。替换为

 <img onclick="openAB()" .... 

关于单击图像时 Javascript 未运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56003633/

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