-2

私はウェブサイトを持っており、javascript関数を取得して、Macで空白を作成しないようにしようとしています。この空白は、更新のたびに増加します。

まず、必要なものを svg で作成し、次にそれを JavaScript でトリガー/制御します。次に、Windows ではないかどうかを検出する JavaScript 関数があります。空白をクリアして、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.")}
};
    }
)();

また、isApple が true のときはいつでもフェード機能をキャンセルしたいと思います。フェードコードは次のとおりです。

$(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);
  });
});

どんな助けでも大歓迎です。

4

1 に答える 1

0

実際に最大ユーザー エージェント文字列にあるものと一致させる必要があります (navigator.userAgent で console.log を実行することで確認できます。「Mac OS X」または「Macintosh」のいずれかを使用してください。ユーザー文字列のサンプルMozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like 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>

ページのヘッダー セクションに、または代わりに要素の CSS で、または<svg width="400" height="200" >たとえば svg タグで直接、幅と高さを割り当てることができ、すべてがその下に適切に配置されます。

于 2013-10-22T20:39:17.370 に答える