Html 为什么我的按钮在被点击后消失了
我的按钮正在按我需要的方式运行,除非它被点击时完全消失。为什么要这样做Html 为什么我的按钮在被点击后消失了,html,forms,button,Html,Forms,Button,我的按钮正在按我需要的方式运行,除非它被点击时完全消失。为什么要这样做 <script type="text/javascript"> function randomlinks(){ var myrandom=Math.round(Math.random()*6) var links=new Array() links[0]="https://abantutogether.org/" links[1]="
<script type="text/javascript">
function randomlinks(){
var myrandom=Math.round(Math.random()*6)
var links=new Array()
links[0]="https://abantutogether.org/"
links[1]="https://abantutogether.org/about-us"
links[2]="https://abantutogether.org/donate"
links[3]="https://abantutogether.org/get-involved"
links[4]="https://abantutogether.org/blog"
links[5]="https://abantutogether.org/contact-us"
links[6]="https://abantutogether.org/sponsor-a-child"
window.open(links[myrandom])
}
</script>
<form>
<input type="image" src="https://i.postimg.cc/43PDgqnZ/Logo-Pix-Teller-1.png" value="random link!" onClick="randomlinks()">
</form>
函数随机链接(){
var myrandom=Math.round(Math.random()*6)
var links=新数组()
链接[0]=”https://abantutogether.org/"
链接[1]=”https://abantutogether.org/about-us"
链接[2]=”https://abantutogether.org/donate"
链接[3]=”https://abantutogether.org/get-involved"
链接[4]=”https://abantutogether.org/blog"
链接[5]=”https://abantutogether.org/contact-us"
链接[6]=”https://abantutogether.org/sponsor-a-child"
打开(链接[myrandom])
}
当您单击按钮时,会打开另一个选项卡/浏览器窗口,页面正在提交。这是你期望的行为吗
在这种情况下,表单提交听起来很奇怪(在form
标记中没有设置action
属性)。也许您不希望在表单中包含此输入,或者您也可以通过如下更改onclick属性来避免子mmit:
onClick="randomlinks(); return false;"