不带按钮的运行脚本

问题描述 投票:0回答:2

我在<button>中有此代码,并且运行脚本来查询数据库中的信息。我想在加载页面时使功能启动,而不必使用按钮,该怎么做?

button {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  display: inline-block;
  padding: .625rem 1.25rem;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: .25rem;
  color: #fff;
  border-color: #5e72e4;
  background-color: #5e72e4;
  box-shadow: 0 4px 6px rgba(50, 50, 93, .11), 0 1px 3px rgba(0, 0, 0, .08);
  cursor: pointer;
}
<button onclick="gtaller_modal();" id="gtaller_modal" data-gt-ventana="1">Button Text</button>

<script src="https://gestioo.com/gwidget/js/gtaller_modal.min.js"></script>
<!-- Confiugracion: data-gt-ventana="1" //Ventana nueva (0/1) -->
javascript html events onload
2个回答
2
投票

您可以在页面加载后使用onload事件启动功能。参见onload event


0
投票

记住要链接脚本

© www.soinside.com 2019 - 2024. All rights reserved.