簡體   English   中英

Javascript 自動標簽不適用於 iPad 或 iPhone

[英]Javascript auto tab not working on iPad or iPhone

我有這段 html 代碼:

    <form name="postcode" method="post" onsubmit="return OnSubmitForm();">
<input class="postcode" maxlength="1" size="1" name="c" onKeyup="autotab(this, document.postcode.o)" /> 
<input class="postcode" maxlength="1" size="1" name="o" onKeyup="autotab(this, document.postcode.d)" /> 
<input class="postcode" maxlength="1" size="1" name="d" onKeyup="autotab(this, document.postcode.e)" /> 
<input class="postcode" maxlength="1" size="1" name="e" /> <br />
    </form>

它使用這個 javascript:

<script>
/*
Auto tabbing script- By JavaScriptKit.com
http://www.javascriptkit.com
This credit MUST stay intact for use
*/
function autotab(original,destination){
if (original.getAttribute&&original.value.length==original.getAttribute("maxlength"))
destination.focus()
}
</script><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js" type="text/javascript"></script>
<script src="js/scripts.js" type="text/javascript"></script>

<script type="text/javascript">
function OnSubmitForm()
{
  if(document.postcode.operation[0].checked == true)
  {
    document.postcode.action ="plans.php";
  }
  else
  if(document.postcode.operation[1].checked == true)
  {
    document.postcode.action ="plans_gas.php";
  }
  else
  if(document.postcode.operation[2].checked == true)
  {
    document.postcode.action ="plans_duel.php";
  }

  return true;
}
</script>

只要您在其中一個文本框中輸入一個字符,它就會自動切換到下一個文本框。

這在 pc 或 mac 和 safari 以及所有其他瀏覽器上都可以正常工作。 但是在 iPad 或 iPhone(使用 safari)上查看網頁時,自動跳轉 function 不起作用。

關於如何使自動標簽在這些移動設備上工作的任何想法?

根據設計,據我所知,焦點在移動設備 Safari 的輸入字段上被禁用。

在我上次使用手機 Safari 時,我需要將事件“onKeyUp”更改為“onKeyPress”,你試過了嗎?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM