Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/390.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript函数可以在windows上工作,但不能在mac上创建空白_Javascript - Fatal编程技术网

Javascript函数可以在windows上工作,但不能在mac上创建空白

Javascript函数可以在windows上工作,但不能在mac上创建空白,javascript,Javascript,我有一个网站,我试图让我的javascript函数不在mac上创建一个空白,这个空白会随着每次刷新而增加 首先,我在svg中创建了我想要的东西,然后用javascript触发/控制它。然后我有一个javascript函数来检测它是否是windows。我是否可以清除空白,在mac和windows上都使用,并且仍然可以工作 我不会发布导致空白的代码,因为我不知道是什么导致了它 以下是检测代码: (function() { if (navigator.userAgent.match(/webOS X/

我有一个网站,我试图让我的javascript函数不在mac上创建一个空白,这个空白会随着每次刷新而增加

首先,我在svg中创建了我想要的东西,然后用javascript触发/控制它。然后我有一个javascript函数来检测它是否是windows。我是否可以清除空白,在mac和windows上都使用,并且仍然可以工作

我不会发布导致空白的代码,因为我不知道是什么导致了它

以下是检测代码:

(function() {
if (navigator.userAgent.match(/webOS X/i)
        || navigator.userAgent.match(/iPhone/i)
        || navigator.userAgent.match(/iPad/i)
        || navigator.userAgent.match(/iPod/i)
        ) {
    isApple = true;
    if (confirm("Because this is a Apple device, It is not reccommended for you to view this site on this device. You will now be transferred to Google.com. I am working on a fix. Thank you for your patience.")){
    window.location = "https://www.google.com";
    }else{
    alert("It is NOT recommended that you view this site at this time. I am working on a fix. Please leave this site now.")}
};
    }
)();
我还想取消淡入淡出功能时,我应用真。以下是淡入淡出的代码:

$(document).ready(function fade(){
  window.onload = (function(){
$("#circ1").fadeIn();
$("#circ2").fadeIn("slow");
$("#circ3").fadeIn(800);
$("#circ4").fadeIn(900);
$("#circ5").fadeIn(1000);
$("#circ6").fadeIn(1100);
$("#circ7").fadeIn(1200);
$("#circ8").fadeIn(1250);
$("#circ9").fadeIn(1300);
$("#circ10").fadeIn(1350);
$("#circ11").fadeIn(1400);
$("#circ12").fadeIn(1450);
$("#circ13").fadeIn(1500);
$("#circ14").fadeIn(1550);
$("#circ15").fadeIn(1600);

$("#circ1").fadeOut();
$("#circ2").fadeOut("slow");
$("#circ3").fadeOut(800);
$("#circ4").fadeOut(900);
$("#circ5").fadeOut(1000);
$("#circ6").fadeOut(1100);
$("#circ7").fadeOut(1200);
$("#circ8").fadeOut(1250);
$("#circ9").fadeOut(1300);
$("#circ10").fadeOut(1350);
$("#circ11").fadeOut(1400);
$("#circ12").fadeOut(1450);
$("#circ13").fadeOut(1500);
$("#circ14").fadeOut(1550);
$("#circ15").fadeOut(1600);
  });
});

非常感谢您的帮助。

您需要匹配max user agent字符串中的实际内容(您可以通过在navigator.userAgent上执行console.log来查看您的内容。使用“Mac OS X”或“Macintosh”。示例用户字符串
Mozilla/5.0(Macintosh;Intel Mac OS X 10_7_5)AppleWebKit/537.36(KHTML,如Gecko)Chrome/29.0.1547.65 Safari/537.36

$(document).ready(function(){

    (function() 
    {
        if (navigator.userAgent.match(/Mac OS X/i)
            || navigator.userAgent.match(/iPhone/i)
            || navigator.userAgent.match(/iPad/i)
            || navigator.userAgent.match(/iPod/i)
            ) 
      {
        isApple = true;
        if (confirm("Because this is a Apple device, It is not reccommended for you to view this site on this device. You will now be transferred to Google.com. I am working on a fix. Thank you for your patience.")){
          window.location = "https://www.google.com";
          }else{
          alert("It is NOT recommended that you view this site at this time. I am working on a fix. Please leave this site now.")}
      }else{
       loadFade();
      } 
    })();

    function loadFade(){
        $("#circ1").fadeIn();
        $("#circ2").fadeIn("slow");
        $("#circ3").fadeIn(800);
        $("#circ4").fadeIn(900);
        $("#circ5").fadeIn(1000);
        $("#circ6").fadeIn(1100);
        $("#circ7").fadeIn(1200);
        $("#circ8").fadeIn(1250);
        $("#circ9").fadeIn(1300);
        $("#circ10").fadeIn(1350);
        $("#circ11").fadeIn(1400);
        $("#circ12").fadeIn(1450);
        $("#circ13").fadeIn(1500);
        $("#circ14").fadeIn(1550);
        $("#circ15").fadeIn(1600);

        $("#circ1").fadeOut();
        $("#circ2").fadeOut("slow");
        $("#circ3").fadeOut(800);
        $("#circ4").fadeOut(900);
        $("#circ5").fadeOut(1000);
        $("#circ6").fadeOut(1100);
        $("#circ7").fadeOut(1200);
        $("#circ8").fadeOut(1250);
        $("#circ9").fadeOut(1300);
        $("#circ10").fadeOut(1350);
        $("#circ11").fadeOut(1400);
        $("#circ12").fadeOut(1450);
        $("#circ13").fadeOut(1500);
        $("#circ14").fadeOut(1550);
        $("#circ15").fadeOut(1600);

    };
});
对于空白,则取决于填充屏幕的svg。如果您希望将其保留在左侧,并将内容保留为不存在,只需添加:

<style type="text/css">
svg { position: absolute;}
</style>

svg{位置:绝对;}

例如,您可以在CSS中为元素或直接在svg标记中为页面的标题部分指定宽度和高度,然后所有内容都将正确对齐。

发布的代码与空白有什么关系?我在Mac上运行Chrome,我的用户代理与这些内容都不匹配ngs。我刚在我的Mac上检查了Safari,它也不匹配。什么是webOS X?是的,webOSX永远不会匹配。我在下面给出了详细信息。对。我没有检查windows,因为它在那里工作正常。关于空白,我没有导致空白的代码,因为我不知道是什么导致空白。我只需要一些代码,可以得到r你有没有像我上面所展示的那样尝试更新嗅探mac的代码,以消除导致问题的原因?空白可能与错误代码有关,但如果没有看到你的html(可能是换行类型或其他很多东西),这是不可能的。是的。现在它的行为与ipod/iphone/ipad一样。它加载警告,但如果单击“取消”和“确定”,仍然会加载淡入淡出。当iApple为真时,我们可以禁用淡入淡出功能吗?在我的回答中更新。现在,淡入淡出根本没有加载。这几乎就像iApple检测不起作用。我没有收到警告。