首页 > 解决方案 > 提交表单按钮未在 Safari 中运行 onclick() javascript 函数

问题描述

提交表单按钮未提交并在 Safari 9 及以上版本中丢失样式。它适用于 Chrome 和 Firefox。我看过一些有类似问题的帖子,但提出的所有解决方案都对我不起作用。

在 JS 中,我在按钮中有一个事件处理程序 onsubmit 和一个 onclick 函数来检查字段是否为空,并触发一个弹出窗口,其中信息由 onsubmit 事件处理程序打印。没有在这里粘贴非常庞大的JS代码......

谢谢:

这是该项目的链接:

https://github.com/carlosrbatalha/survey-saving-our-planet

编码:

 HTML:

    <div class="outer-button">
    <button form="survey-form" id="submit" type="submit" name="submit" onclick='myFunction()'>Submit</button>
    </div>

    CSS:

        .outer-button {

      display: flex;
      flex-direction: row;
      justify-content: center;
      padding-bottom: 50px;
    }

#submit {
  background-color: rgba(255,255,255, 0.7);
  display: flex;

   border:none;
  -webkit-border:none;
  -webkit-border-radius:0px;
  -webkit-appearance:default-button;


  justify-content: center;
  align-self: center;
  width: 100px;

  padding:10px;

  margin-top: 20px;
  font-family: 'Varela Round', sans-serif;
  font-size: calc(9px + (21 - 9) * ((100vw - 300px) / (1600 - 300)));  
  cursor: pointer; 
}

#submit:hover{
  background-color: rgba(255,255,255, 1);
  border: none;
  -webkit-border:none;
  -webkit-border-radius:0px;
  -webkit-appearance:default-button;
  }

标签: javascriptformsbuttonsafarisubmit

解决方案


推荐阅读