2015年3月9日月曜日

__defineGetter__()じゃなくて、defineProperty()にしようかな [ WEB ]

あ、なんか、__defineGetter__()はMDNを見るとすでに非推奨ぽいな。
なので、Object.definePropertyを使おうかな・・・
そんでもって、前回のフルスクリーンのやつを書き換えておく。
if(!document.fullscreenElement)
  document.__defineGetter__("fullscreenElement", function(){
    return(
      document.msFullscreenElement ||
      document.webkitFullscreenElement ||
      document.mozFullScreenElement || null);
  });
これを書き換えて、
if(!document.fullscreenElement)
  Object.defineProperty(document,"fullscreenElement",{
    get : function(){
      return(
        document.msFullscreenElement ||
        document.webkitFullscreenElement ||
        document.mozFullScreenElement || null);
    }
  });
こんな感じになりましたとさ、めでたしめでたし。


修正:2016/02/09 [ソース中] FullscreenElement → fullscreenElement
追記:ベンダープレフィックスなしで、フルスクリーン表示

ふんどしの持ち主

0 件のコメント:

コメントを投稿