Javascript Wordpress插件功能在桌面上运行良好,但在移动设备上运行不正常。为什么?

Javascript Wordpress插件功能在桌面上运行良好,但在移动设备上运行不正常。为什么?,javascript,php,jquery,wordpress,shortcode,Javascript,Php,Jquery,Wordpress,Shortcode,我已经为我们的Wordpress网站https//speaktoday.com创建了一个Wordpress Accenttext-to-speech插件/快捷码。它的功能在桌面上运行良好,但每当我打开它时,手机就会显示一个弹出窗口speaktoday.com想要使用语音拒绝和允许。此外,它的文字语音转换功能在移动设备中也不起作用。 我不想在手机上打开我的网站时显示弹出消息,而且插件的功能在手机上也应该可以正常工作。 请给我一个合适的解决办法 这是我的密码: <?php /** Pl

我已经为我们的Wordpress网站https//speaktoday.com创建了一个Wordpress Accenttext-to-speech插件/快捷码。它的功能在桌面上运行良好,但每当我打开它时,手机就会显示一个弹出窗口speaktoday.com想要使用语音拒绝和允许。此外,它的文字语音转换功能在移动设备中也不起作用。 我不想在手机上打开我的网站时显示弹出消息,而且插件的功能在手机上也应该可以正常工作。 请给我一个合适的解决办法

这是我的密码:

    <?php
/** Plugin Name: SpeakToday_Accent
    Description: This plugin is used to select preferred accent
    Author: Amit  Singh
    Version: 1.0
    link : https://speaktoday.com

*/
add_shortcode( 'TTSdefault', 'voice_counter' );
function voice_counter($att,$content){
    $att = shortcode_atts(array('lang' => ''),$att);
    $languageVal = $att['lang'];
    //echo "<h2>".$languageVal."</h2>";

?>

<script src="https://code.responsivevoice.org/responsivevoice.js"></script>
<script src="//code.responsivevoice.org/1.5.6/responsivevoice.js"></script>

<script>
setTimeout(responsiveVoice.speak("",$('#voiceselection').val()),15000);
</script>
<script>



function getSelectionText() {
    var text = "";
    if (window.getSelection) {
        text = window.getSelection().toString();

    } else if (document.selection && document.selection.type != "Control") { 
        text = document.selection.createRange().text;
    }
    return text;
}
$(document).ready(function (){ 
   $(document).mouseup(function (e){ 
      setTimeout(function() { 
         responsiveVoice.cancel(); 
         var text = $('#voiceselection').val();
          responsiveVoice.speak(getSelectionText(), text ); 

      }, 1);
   });
});
</script>
<div class = "speaktoday_accent" style="background:white;width:155px; position: relative !important;transform: none !important; display: inline-block;">
 <select id="voiceselection" style="width:155;line-height:2;">
  <option value="UK English Female">UK English Female</option>
    <option value="US English Female">US English Female</option>
    <option value="Hindi Female">Hindi Female</option>
    <option value="UK English Male">UK English Male</option>
    <option value="US English Male">US English Male</option>
     </select>
</div>

<script>
    var spge = <?php echo json_encode($languageVal); ?>;
    //alert(spge);
         $("#voiceselection").on('change', function () {
             window.localStorage.setItem("voiceselection", this.value);
        });
        $(document).ready(function () {
            var n = sessionStorage.getItem('on_load_counter');
             if (n === null) {
             n = 0;
             }
              n++;
            sessionStorage.setItem("on_load_counter", n);

            if(n>1){
                 $("#voiceselection").val(window.localStorage.getItem("voiceselection"));
                $('select option[value="voiceselection"]').attr("selected",true);
            }
            else{

                //alert(spge);
            // $("#voiceselection").val(window.localStorage.getItem("voiceselection"));

            //alert(spge);
            $("#voiceselection").val(spge).change();
                //$('select option[value="UK English Female"]').attr("selected",true);
            }

            //alert(n);
        });
</script>


<?php

}
请帮我解决这些问题。 你可以访问看看那个插件。向下滚动时,您将看到语言选择下拉列表


提前感谢

不幸的是,在提示下无法允许使用设备硬件的权限。想象一下,任何网站都可以在未经同意的情况下只听麦克风。您很可能已经在桌面上允许了权限,并且已经记住了它


此外,移动设备没有mouseup事件。请尝试使用模糊事件,或更改取消超时。

为什么“不幸”?这对Amit来说是不幸的?我的意思是,从逻辑上讲,没有人愿意在他的设备上有一个大洞,比如使用某个网站上的设备硬件