Javascript Can';t在移动设备上的输入字段中键入文本,但在桌面上工作

Javascript Can';t在移动设备上的输入字段中键入文本,但在桌面上工作,javascript,jquery,html,css,input,Javascript,Jquery,Html,Css,Input,我放置了一个jQuery颜色框,用于显示文本输入字段,但由于某些原因,我无法在手机上键入输入字段。但它在我的桌面上工作。当我把光标放在某个字段上时,它不会放在输入字段上。而是开始加载。然后将我带回默认位置(colorbox仍处于打开状态,我无法将光标放置在文本字段上。将光标和文本放置到字段中的唯一方法是在文本字段上等待一段时间。然后出现“粘贴”选项。因此我可以将文本粘贴到文本字段中,但我无法键入 HTML(出现在颜色框中的表单): <div class="compare" style="

我放置了一个jQuery颜色框,用于显示文本输入字段,但由于某些原因,我无法在手机上键入输入字段。但它在我的桌面上工作。当我把光标放在某个字段上时,它不会放在输入字段上。而是开始加载。然后将我带回默认位置(colorbox仍处于打开状态,我无法将光标放置在文本字段上。将光标和文本放置到字段中的唯一方法是在文本字段上等待一段时间。然后出现“粘贴”选项。因此我可以将文本粘贴到文本字段中,但我无法键入


HTML(出现在颜色框中的表单):

<div class="compare" style="margin-top: 20px;"><a id="fast_order" href="#fast_order_form" class="button" />Купить в 1 клик</a></div>    
    <div style="display:none">
        <div id="fast_order_form">       
            <input id="product_name" type="hidden" value="<?php echo $heading_title; ?>">
            <input id="product_price" type="hidden" value="<?php echo ($special ? $special : $price); ?>">
            <div class="fast_order_center"><?php echo $heading_title; ?> — ваш заказ</div>

        <div class="fast_order_left">
        <p>Имя:</p>
        <p>Телефон:</p>
        <p>Комментарий:</p>
        </div>

        <div class="fast_order_right">
        <p><input type="text" id="customer_name"/></p>
        <p><input type="text" id="customer_phone"/></p>
        <p><input type="text" id="customer_message"/></p>
        </div>

        <div class="fast_order_center">
        <p id="fast_order_result">Пожалуйста, укажите ваше имя и телефон</p>
        <button class="fast_order_button"><span>Подтвердить</span></button> 
        </div>
    </div>
</div>

颜色框按钮单击处理程序:

$(document).ready(function () {
    $('#fast_order').colorbox({href:"#fast_order_form",inline:true, width:"650px", height:"330px", class: "colorbox", title:" "});
    $('#fast_order_form .fast_order_center button').click(function () {
      var product_name = $('#product_name').val(); 
      var product_price = $('#product_price').val();
      var customer_name = $('#customer_name').val();
      var customer_phone = $('#customer_phone').val();
      var customer_message = $('#customer_message').val();
      $('#result').html('Обрабатываем введенные данные..');
     // $.post('./fast_order.php', { 'product_name': product_name, 'product_price': product_price, 'customer_name': customer_name, 'customer_phone': customer_phone, 'customer_message': customer_message }, function (data) { if (data == 'empty') { $('#fast_order_result').html('<span class="fast_order_error">Обязательно укажите ваше имя и телефон, иначе мы не сможем вам перезвонить!</span>'); } else { $('#fast_order_result').html('<span class="fast_order_success">Ваш заказ успешно оформлен!</span><br /><span>Мы перезвоним вам в течение дня. <a onclick="$(window).colorbox.close();">Закрыть</a> это окно?</span>'); } });
    $.post('http://chico.esy.es/fast_order.php', { 'product_name': product_name, 'product_price': product_price, 'customer_name': customer_name, 'customer_phone': customer_phone, 'customer_message': customer_message }, function (data) { if (data == 'empty') { $('#fast_order_result').html('<span class="fast_order_error">Обязательно укажите ваше имя и телефон, иначе мы не сможем вам перезвонить!</span>'); } else { $('.fast_order_button').css('display','none'); $('#fast_order_result').html('<span class="fast_order_success">Ваш заказ успешно оформлен!</span><br /><span>Мы перезвоним вам в течение дня. <a onclick="$(window).colorbox.close();">Закрыть</a> это окно?</span>'); } });
    });
});
$(文档).ready(函数(){
$('fast_order').colorbox({href:'fast_order_form',inline:true,宽度:“650px”,高度:“330px”,类:“colorbox”,标题:“});
$(“#快速订购表格。快速订购中心按钮”)。单击(函数(){
var product_name=$('#product_name').val();
var product_price=$(“#product_price”).val();
var customer_name=$('#customer_name').val();
var customer_phone=$('#customer_phone').val();
var customer_message=$('#customer_message').val();
$(“#result').html(';
//$.post('./fast\u order.php',{'product\u name':product\u name,'product\u price':product\u price,'customer\u name':customer\u name,'customer\u phone':customer\u phone,'customer\u message':customer\u message},函数(数据){if(data='empty'){$('fast\u order\u result').html在这两个地区,他们是从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从到到到到到到到从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从到到到到到到到到到到到到到到到到从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从从ааааааааааааааааа;
$.post($)http://chico.esy.es/fast_order.php“,{product_name':product_name,'product_price':product_price,'customer_name':customer_name,'customer_phone':customer_phone,'customer_message':customer_message},函数(数据){if(数据='empty'){$('fast#order_result').html其他{$('fast\u order\u button').css('display','none');$('fast\u order\u result')。html(“азззззззззззззззззззззззззззззз;
});
});


更新:

$(document).ready(function () {
    $('#fast_order').colorbox({href:"#fast_order_form",inline:true, width:"650px", height:"330px", class: "colorbox", title:" "});
    $('#fast_order_form .fast_order_center button').click(function () {
      var product_name = $('#product_name').val(); 
      var product_price = $('#product_price').val();
      var customer_name = $('#customer_name').val();
      var customer_phone = $('#customer_phone').val();
      var customer_message = $('#customer_message').val();
      $('#result').html('Обрабатываем введенные данные..');
     // $.post('./fast_order.php', { 'product_name': product_name, 'product_price': product_price, 'customer_name': customer_name, 'customer_phone': customer_phone, 'customer_message': customer_message }, function (data) { if (data == 'empty') { $('#fast_order_result').html('<span class="fast_order_error">Обязательно укажите ваше имя и телефон, иначе мы не сможем вам перезвонить!</span>'); } else { $('#fast_order_result').html('<span class="fast_order_success">Ваш заказ успешно оформлен!</span><br /><span>Мы перезвоним вам в течение дня. <a onclick="$(window).colorbox.close();">Закрыть</a> это окно?</span>'); } });
    $.post('http://chico.esy.es/fast_order.php', { 'product_name': product_name, 'product_price': product_price, 'customer_name': customer_name, 'customer_phone': customer_phone, 'customer_message': customer_message }, function (data) { if (data == 'empty') { $('#fast_order_result').html('<span class="fast_order_error">Обязательно укажите ваше имя и телефон, иначе мы не сможем вам перезвонить!</span>'); } else { $('.fast_order_button').css('display','none'); $('#fast_order_result').html('<span class="fast_order_success">Ваш заказ успешно оформлен!</span><br /><span>Мы перезвоним вам в течение дня. <a onclick="$(window).colorbox.close();">Закрыть</a> это окно?</span>'); } });
    });
});
我找到了导致问题的代码片段,但无法找出问题所在

<script type="text/javascript">
        jQuery.colorbox.settings.maxWidth  = '95%';
        jQuery.colorbox.settings.maxHeight = '95%';

        var resizeTimer;
        function resizeColorBox()
        {
            if (resizeTimer) clearTimeout(resizeTimer);
            resizeTimer = setTimeout(function() {
                if (jQuery('#cboxOverlay').is(':visible')) {
                    jQuery.colorbox.load(true);
                }
            }, 300);
        }

        jQuery(window).resize(resizeColorBox);
        window.addEventListener("orientationchange", resizeColorBox, false);
    </script>

jQuery.colorbox.settings.maxWidth='95%';
jQuery.colorbox.settings.maxHeight='95%';
var树脂定时器;
函数resizeColorBox()
{
if(resizeTimer)clearTimeout(resizeTimer);
resizeTimer=setTimeout(函数(){
if(jQuery('#cboxOverlay').is(':visible')){
jQuery.colorbox.load(true);
}
}, 300);
}
jQuery(窗口).resize(resizeColorBox);
window.addEventListener(“方向更改”,resizeColorBox,false);

例如,如果我设置了30000而不是300,那么一切都正常。谁知道如何正确解决这个问题呢?

不要设置超时,而是尝试在窗口加载完成后再执行代码。毕竟,这就是(我假设)您试图通过超时来完成的。尝试以下方法:

$(document).ready(function(){

    //your script here

});
如果这不起作用,您可以始终将脚本置于
.ready()
内的超时状态。这样,它就不必像超时那样长,才能继续工作