【问题标题】:javascript onclick cancel focusjavascript onclick 取消焦点
【发布时间】:2013-12-11 06:48:47
【问题描述】:

我从动作发布方法中返回确认。代码正在运行,但当确认到来时我需要关注取消。但总是好的是专注的。我如何解决这个问题

我的代码在下面..

*

<script type="text/javascript">
function confirmation() {
var consumption = document.getElementById("consumption").value;
var texthere1 = document.getElementById("texthere1").value;
var line = document.getElementById("texthere").value;
return confirm("You are about to issue Material <?php echo ltrim($data , "0") ;  ?> from 2100/<?php echo ($data2 ) ;  ?> To a Dying STO " + texthere1 + " At line " + line + " of " + consumption + " KG. Are You Sure ?")   ;  
return false;   
}
</script>
<form action="a.php" method="post">
<input name="Submit" type="submit" value="Submit" onclick="return confirmation()">
</form>

*

【问题讨论】:

  • 我认为您无法对此进行控制,您可以使用 modalpopup insted 并关注它
  • 您无法更改浏览器生成对话框的默认行为。您可以使用 js 和 css 创建自己的确认对话框。

标签: javascript onclick confirm


【解决方案1】:

我认为不可能这样做,请参阅此类似帖子:JavaScript: How to select "Cancel" by default in confirm box?

【讨论】:

    【解决方案2】:

    当使用这个来确认时

    document.getElementById('id').blur();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-10-28
      • 1970-01-01
      • 2016-05-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多